blackshard83
Posts: 72
Joined: Fri Jan 10, 2014 8:31 am

Reduce VRAM fragmentation

Thu Feb 22, 2018 12:10 pm

Hello,

I'm working on a font rendering engine that uses vector paths and renders them via OpenVG.
Everything works fine at the moment, but using paths for font glyphs causes a lot of free blocks inside video memory.
I provide exact segment and coords hints for the paths, create them using vgCreatePath with only VG_APPEND_PATH_TO capability, append data at once using vgAppendPathData, and at last removing the capabilities.
Data is in signed 16 bit integer format and once a glyph is stored it is never removed.

Using vcdbg reloc I notice there are a lot of small free blocks, mainly of 32 bytes each. This is a typical log:

Code: Select all

Relocatable heap version 4 found at 0x10000000
total space allocated is 236M, with 234M relocatable, 2.3M legacy and 0 offline
1 legacy blocks of size 2359296

free list at 0x1de3e0c0
220M free memory in 66 free block(s)
largest free block is 220M bytes

0x10000000: legacy block 2.3M
0x10240000: free 220M
[ 587] 0x1dde41e0: used  96K (refcount 1 lock count 0, size    98304, align  256, data 0x1dde4200, D1ruAl) 'khrn_hw_bin_mem'
[  33] 0x1ddfc300: used 1.4K (refcount 1 lock count 0, size     1328, align    4, data 0x1ddfc320, D1Rual) 'vg_spath'
0x1ddfc880: free 32
[ 246] 0x1ddfc8a0: used  704 (refcount 1 lock count 0, size      624, align    4, data 0x1ddfc8c0, D1Rual) 'vg_spath'
0x1ddfcb60: free 288
[ 133] 0x1ddfcc80: used 1.4K (refcount 1 lock count 0, size     1368, align    4, data 0x1ddfcca0, D1Rual) 'vg_spath'
0x1ddfd220: free 192
[  40] 0x1ddfd2e0: used  416 (refcount 1 lock count 0, size      344, align    4, data 0x1ddfd300, D1Rual) 'vg_spath'
0x1ddfd480: free 64
[ 225] 0x1ddfd4c0: used 1.1K (refcount 1 lock count 0, size     1024, align    4, data 0x1ddfd4e0, D1Rual) 'vg_spath'
0x1ddfd900: free 352
[ 334] 0x1ddfda60: used 1.1K (refcount 1 lock count 0, size     1088, align    4, data 0x1ddfda80, D1Rual) 'vg_spath'
0x1ddfdee0: free 288
[ 199] 0x1ddfe000: used 1.1K (refcount 1 lock count 0, size     1008, align    4, data 0x1ddfe020, D1Rual) 'vg_spath'
0x1ddfe440: free 352
[  23] 0x1ddfe5a0: used 1.2K (refcount 1 lock count 0, size     1128, align    4, data 0x1ddfe5c0, D1Rual) 'vg_spath'
0x1ddfea60: free 224
[ 424] 0x1ddfeb40: used 1.2K (refcount 1 lock count 0, size     1184, align    4, data 0x1ddfeb60, D1Rual) 'vg_spath'
0x1ddff020: free 192
[ 461] 0x1ddff0e0: used 1.1K (refcount 1 lock count 0, size     1048, align    4, data 0x1ddff100, D1Rual) 'vg_spath'
0x1ddff540: free 320
[ 577] 0x1ddff680: used  704 (refcount 1 lock count 0, size      624, align    4, data 0x1ddff6a0, D1Rual) 'vg_spath'
0x1ddff940: free 288
[  51] 0x1ddffa60: used  768 (refcount 1 lock count 0, size      704, align    4, data 0x1ddffa80, D1Rual) 'vg_spath'
0x1ddffd60: free 224
[ 118] 0x1ddffe40: used  704 (refcount 1 lock count 0, size      624, align    4, data 0x1ddffe60, D1Rual) 'vg_spath'
0x1de00100: free 288
[ 536] 0x1de00220: used  704 (refcount 1 lock count 0, size      624, align    4, data 0x1de00240, D1Rual) 'vg_spath'
0x1de004e0: free 288
[ 109] 0x1de00600: used 1.0K (refcount 1 lock count 0, size      944, align    4, data 0x1de00620, D1Rual) 'vg_spath'
0x1de00a00: free 416
[ 274] 0x1de00ba0: used 1.3K (refcount 1 lock count 0, size     1304, align    4, data 0x1de00bc0, D1Rual) 'vg_spath'
0x1de01100: free 64
[ 253] 0x1de01140: used  928 (refcount 1 lock count 0, size      848, align    4, data 0x1de01160, D1Rual) 'vg_spath'
0x1de014e0: free 64
[ 284] 0x1de01520: used 1.2K (refcount 1 lock count 0, size     1128, align    4, data 0x1de01540, D1Rual) 'vg_spath'
0x1de019e0: free 224
[ 451] 0x1de01ac0: used 1.1K (refcount 1 lock count 0, size     1064, align    4, data 0x1de01ae0, D1Rual) 'vg_spath'
0x1de01f40: free 288
[ 403] 0x1de02060: used 1.0K (refcount 1 lock count 0, size      944, align    4, data 0x1de02080, D1Rual) 'vg_spath'
0x1de02460: free 416
[ 121] 0x1de02600: used 1.0K (refcount 1 lock count 0, size      984, align    4, data 0x1de02620, D1Rual) 'vg_spath'
0x1de02a20: free 384
[ 179] 0x1de02ba0: used 1.4K (refcount 1 lock count 0, size     1328, align    4, data 0x1de02bc0, D1Rual) 'vg_spath'
0x1de03120: free 32
[ 314] 0x1de03140: used 1.3K (refcount 1 lock count 0, size     1264, align    4, data 0x1de03160, D1Rual) 'vg_spath'
0x1de03680: free 96
[ 390] 0x1de036e0: used 1.0K (refcount 1 lock count 0, size      968, align    4, data 0x1de03700, D1Rual) 'vg_spath'
0x1de03b00: free 384
[ 523] 0x1de03c80: used  672 (refcount 1 lock count 0, size      584, align    4, data 0x1de03ca0, D1Rual) 'vg_spath'
[ 564] 0x1de03f20: used 1.3K (refcount 1 lock count 0, size     1248, align    4, data 0x1de03f40, D1Rual) 'vg_spath'
0x1de04440: free 128
[ 389] 0x1de044c0: used 1.0K (refcount 1 lock count 0, size      984, align    4, data 0x1de044e0, D1Rual) 'vg_spath'
0x1de048e0: free 384
[ 459] 0x1de04a60: used  608 (refcount 1 lock count 0, size      544, align    4, data 0x1de04a80, D1Rual) 'vg_spath'
0x1de04cc0: free 64
[ 440] 0x1de04d00: used 1.2K (refcount 1 lock count 0, size     1168, align    4, data 0x1de04d20, D1Rual) 'vg_spath'
0x1de051e0: free 192
[ 362] 0x1de052a0: used 1.3K (refcount 1 lock count 0, size     1248, align    4, data 0x1de052c0, D1Rual) 'vg_spath'
0x1de057c0: free 128
[  15] 0x1de05840: used  896 (refcount 1 lock count 0, size      824, align    4, data 0x1de05860, D1Rual) 'vg_spath'
0x1de05bc0: free 96
[ 129] 0x1de05c20: used 1.1K (refcount 1 lock count 0, size     1024, align    4, data 0x1de05c40, D1Rual) 'vg_spath'
0x1de06060: free 352
[ 428] 0x1de061c0: used  96K (refcount 1 lock count 0, size    98304, align  256, data 0x1de06200, D1ruAl) 'khrn_hw_bin_mem'
[  25] 0x1de1e2e0: used  96K (refcount 1 lock count 0, size    98304, align  256, data 0x1de1e300, D1ruAl) 'khrn_hw_bin_mem'
[  49] 0x1de36400: used  320 (refcount 1 lock count 0, size      248, align    4, data 0x1de36420, d0RUal) 'VG_PATH_T.coords'
0x1de36540: free 32
[ 341] 0x1de36560: used   96 (refcount 1 lock count 0, size       32, align    1, data 0x1de36580, d0RUal) 'VG_PATH_T.segments'
[ 174] 0x1de365c0: used  192 (refcount 1 lock count 0, size      116, align    4, data 0x1de365e0, d0RUal) 'VG_PATH_T.coords'
0x1de36680: free 32
[  26] 0x1de366a0: used   96 (refcount 1 lock count 0, size       15, align    1, data 0x1de366c0, d0RUal) 'VG_PATH_T.segments'
[  98] 0x1de36700: used  128 (refcount 1 lock count 0, size       60, align    4, data 0x1de36720, d0RUal) 'VG_PATH_T.coords'
0x1de36780: free 32
[ 591] 0x1de367a0: used   96 (refcount 1 lock count 0, size        8, align    1, data 0x1de367c0, d0RUal) 'VG_PATH_T.segments'
[ 460] 0x1de36800: used  320 (refcount 1 lock count 0, size      256, align    4, data 0x1de36820, d0RUal) 'VG_PATH_T.coords'
[  47] 0x1de36940: used  128 (refcount 1 lock count 0, size       33, align    1, data 0x1de36960, d0RUal) 'VG_PATH_T.segments'
[ 516] 0x1de369c0: used  288 (refcount 1 lock count 0, size      196, align    4, data 0x1de369e0, d0RUal) 'VG_PATH_T.coords'
0x1de36ae0: free 32
[ 588] 0x1de36b00: used   96 (refcount 1 lock count 0, size       25, align    1, data 0x1de36b20, d0RUal) 'VG_PATH_T.segments'
[  82] 0x1de36b60: used  288 (refcount 1 lock count 0, size      200, align    4, data 0x1de36b80, d0RUal) 'VG_PATH_T.coords'
0x1de36c80: free 32
[ 419] 0x1de36ca0: used   96 (refcount 1 lock count 0, size       26, align    1, data 0x1de36cc0, d0RUal) 'VG_PATH_T.segments'
[ 197] 0x1de36d00: used  256 (refcount 1 lock count 0, size      184, align    4, data 0x1de36d20, d0RUal) 'VG_PATH_T.coords'
0x1de36e00: free 32
[ 548] 0x1de36e20: used   96 (refcount 1 lock count 0, size       24, align    1, data 0x1de36e40, d0RUal) 'VG_PATH_T.segments'
[  46] 0x1de36e80: used  288 (refcount 1 lock count 0, size      208, align    4, data 0x1de36ea0, d0RUal) 'VG_PATH_T.coords'
0x1de36fa0: free 32
[ 131] 0x1de36fc0: used   96 (refcount 1 lock count 0, size       27, align    1, data 0x1de36fe0, d0RUal) 'VG_PATH_T.segments'
[ 196] 0x1de37020: used  320 (refcount 1 lock count 0, size      228, align    4, data 0x1de37040, d0RUal) 'VG_PATH_T.coords'
0x1de37160: free 32
[ 393] 0x1de37180: used   96 (refcount 1 lock count 0, size       29, align    1, data 0x1de371a0, d0RUal) 'VG_PATH_T.segments'
[ 527] 0x1de371e0: used  256 (refcount 1 lock count 0, size      192, align    4, data 0x1de37200, d0RUal) 'VG_PATH_T.coords'
0x1de372e0: free 32
[ 391] 0x1de37300: used   96 (refcount 1 lock count 0, size       25, align    1, data 0x1de37320, d0RUal) 'VG_PATH_T.segments'
[ 526] 0x1de37360: used  192 (refcount 1 lock count 0, size      116, align    4, data 0x1de37380, d0RUal) 'VG_PATH_T.coords'
0x1de37420: free 32
[  38] 0x1de37440: used   96 (refcount 1 lock count 0, size       15, align    1, data 0x1de37460, d0RUal) 'VG_PATH_T.segments'
[ 356] 0x1de374a0: used  160 (refcount 1 lock count 0, size       80, align    4, data 0x1de374c0, d0RUal) 'VG_PATH_T.coords'
0x1de37540: free 32
[ 169] 0x1de37560: used   96 (refcount 1 lock count 0, size       11, align    1, data 0x1de37580, d0RUal) 'VG_PATH_T.segments'
[ 304] 0x1de375c0: used  224 (refcount 1 lock count 0, size      132, align    4, data 0x1de375e0, d0RUal) 'VG_PATH_T.coords'
0x1de376a0: free 32
[ 111] 0x1de376c0: used   96 (refcount 1 lock count 0, size       17, align    1, data 0x1de376e0, d0RUal) 'VG_PATH_T.segments'
[ 350] 0x1de37720: used  192 (refcount 1 lock count 0, size      116, align    4, data 0x1de37740, d0RUal) 'VG_PATH_T.coords'
0x1de377e0: free 32
[ 495] 0x1de37800: used   96 (refcount 1 lock count 0, size       15, align    1, data 0x1de37820, d0RUal) 'VG_PATH_T.segments'
[ 359] 0x1de37860: used   64 (refcount 1 lock count 0, size        0, align    4, data 0x1de37880, d0RUAl) 'VG_PATH_T.coords'
[ 407] 0x1de378a0: used   64 (refcount 1 lock count 0, size        0, align    1, data 0x1de378c0, d0RUAl) 'VG_PATH_T.segments'
[ 394] 0x1de378e0: used  192 (refcount 1 lock count 0, size      116, align    4, data 0x1de37900, d0RUal) 'VG_PATH_T.coords'
0x1de379a0: free 32
[ 214] 0x1de379c0: used   96 (refcount 1 lock count 0, size       15, align    1, data 0x1de379e0, d0RUal) 'VG_PATH_T.segments'
[  54] 0x1de37a20: used  256 (refcount 1 lock count 0, size      180, align    4, data 0x1de37a40, d0RUal) 'VG_PATH_T.coords'
0x1de37b20: free 32
[ 327] 0x1de37b40: used   96 (refcount 1 lock count 0, size       23, align    1, data 0x1de37b60, d0RUal) 'VG_PATH_T.segments'
[  93] 0x1de37ba0: used  320 (refcount 1 lock count 0, size      252, align    4, data 0x1de37bc0, d0RUal) 'VG_PATH_T.coords'
0x1de37ce0: free 32
[ 261] 0x1de37d00: used   96 (refcount 1 lock count 0, size       32, align    1, data 0x1de37d20, d0RUal) 'VG_PATH_T.segments'
[  79] 0x1de37d60: used  224 (refcount 1 lock count 0, size      152, align    4, data 0x1de37d80, d0RUal) 'VG_PATH_T.coords'
0x1de37e40: free 32
[ 210] 0x1de37e60: used   96 (refcount 1 lock count 0, size       20, align    1, data 0x1de37e80, d0RUal) 'VG_PATH_T.segments'
[  32] 0x1de37ec0: used  288 (refcount 1 lock count 0, size      208, align    4, data 0x1de37ee0, d0RUal) 'VG_PATH_T.coords'
0x1de37fe0: free 32
[  16] 0x1de38000: used   96 (refcount 1 lock count 0, size       27, align    1, data 0x1de38020, d0RUal) 'VG_PATH_T.segments'
[ 467] 0x1de38060: used  288 (refcount 1 lock count 0, size      204, align    4, data 0x1de38080, d0RUal) 'VG_PATH_T.coords'
0x1de38180: free 32
[ 353] 0x1de381a0: used   96 (refcount 1 lock count 0, size       26, align    1, data 0x1de381c0, d0RUal) 'VG_PATH_T.segments'
[ 355] 0x1de38200: used  256 (refcount 1 lock count 0, size      180, align    4, data 0x1de38220, d0RUal) 'VG_PATH_T.coords'
0x1de38300: free 32
[ 490] 0x1de38320: used   96 (refcount 1 lock count 0, size       23, align    1, data 0x1de38340, d0RUal) 'VG_PATH_T.segments'
[ 204] 0x1de38380: used  256 (refcount 1 lock count 0, size      188, align    4, data 0x1de383a0, d0RUal) 'VG_PATH_T.coords'
0x1de38480: free 32
[ 360] 0x1de384a0: used   96 (refcount 1 lock count 0, size       24, align    1, data 0x1de384c0, d0RUal) 'VG_PATH_T.segments'
[  31] 0x1de38500: used  320 (refcount 1 lock count 0, size      248, align    4, data 0x1de38520, d0RUal) 'VG_PATH_T.coords'
0x1de38640: free 32
[ 429] 0x1de38660: used   96 (refcount 1 lock count 0, size       32, align    1, data 0x1de38680, d0RUal) 'VG_PATH_T.segments'
[ 458] 0x1de386c0: used  320 (refcount 1 lock count 0, size      244, align    4, data 0x1de386e0, d0RUal) 'VG_PATH_T.coords'
0x1de38800: free 32
[  89] 0x1de38820: used   96 (refcount 1 lock count 0, size       31, align    1, data 0x1de38840, d0RUal) 'VG_PATH_T.segments'
[ 497] 0x1de38880: used  256 (refcount 1 lock count 0, size      176, align    4, data 0x1de388a0, d0RUal) 'VG_PATH_T.coords'
0x1de38980: free 32
[ 273] 0x1de389a0: used   96 (refcount 1 lock count 0, size       23, align    1, data 0x1de389c0, d0RUal) 'VG_PATH_T.segments'
[  34] 0x1de38a00: used  192 (refcount 1 lock count 0, size      108, align    4, data 0x1de38a20, d0RUal) 'VG_PATH_T.coords'
0x1de38ac0: free 32
[  68] 0x1de38ae0: used   96 (refcount 1 lock count 0, size       14, align    1, data 0x1de38b00, d0RUal) 'VG_PATH_T.segments'
[ 117] 0x1de38b40: used  320 (refcount 1 lock count 0, size      232, align    4, data 0x1de38b60, d0RUal) 'VG_PATH_T.coords'
0x1de38c80: free 32
[  13] 0x1de38ca0: used   96 (refcount 1 lock count 0, size       30, align    1, data 0x1de38cc0, d0RUal) 'VG_PATH_T.segments'
[ 583] 0x1de38d00: used  256 (refcount 1 lock count 0, size      188, align    4, data 0x1de38d20, d0RUal) 'VG_PATH_T.coords'
0x1de38e00: free 32
[ 112] 0x1de38e20: used   96 (refcount 1 lock count 0, size       24, align    1, data 0x1de38e40, d0RUal) 'VG_PATH_T.segments'
[  30] 0x1de38e80: used  192 (refcount 1 lock count 0, size      100, align    4, data 0x1de38ea0, d0RUal) 'VG_PATH_T.coords'
0x1de38f40: free 32
[  57] 0x1de38f60: used   96 (refcount 1 lock count 0, size       13, align    1, data 0x1de38f80, d0RUal) 'VG_PATH_T.segments'
[ 388] 0x1de38fc0: used  288 (refcount 1 lock count 0, size      216, align    4, data 0x1de38fe0, d0RUal) 'VG_PATH_T.coords'
0x1de390e0: free 32
[ 427] 0x1de39100: used   96 (refcount 1 lock count 0, size       28, align    1, data 0x1de39120, d0RUal) 'VG_PATH_T.segments'
[ 392] 0x1de39160: used  320 (refcount 1 lock count 0, size      232, align    4, data 0x1de39180, d0RUal) 'VG_PATH_T.coords'
0x1de392a0: free 32
[  80] 0x1de392c0: used   96 (refcount 1 lock count 0, size       30, align    1, data 0x1de392e0, d0RUal) 'VG_PATH_T.segments'
[ 354] 0x1de39320: used  14K (refcount 1 lock count 0, size    14336, align    4, data 0x1de39340, d0RUal) 'VG_FONT_T.slots'
[ 464] 0x1de3cb60: used 4.1K (refcount 1 lock count 0, size     4096, align    4, data 0x1de3cb80, d0rual) 'VG_FONT_T.entries'
[ 114] 0x1de3dba0: used  288 (refcount 1 lock count 0, size      208, align    8, data 0x1de3dbc0, d1Rual) 'vg_shader_fd'
0x1de3dcc0: free 32
[ 349] 0x1de3dce0: used  224 (refcount 1 lock count 0, size      156, align    4, data 0x1de3dd00, d0RUal) 'VG_PATH_T.coords'
0x1de3ddc0: free 32
[  83] 0x1de3dde0: used   96 (refcount 1 lock count 0, size       20, align    1, data 0x1de3de00, d0RUal) 'VG_PATH_T.segments'
[ 406] 0x1de3de40: used  288 (refcount 1 lock count 0, size      196, align    4, data 0x1de3de60, d0RUal) 'VG_PATH_T.coords'
0x1de3df60: free 32
[ 132] 0x1de3df80: used   96 (refcount 1 lock count 0, size       25, align    1, data 0x1de3dfa0, d0RUal) 'VG_PATH_T.segments'
[  20] 0x1de3dfe0: used  128 (refcount 1 lock count 0, size       64, align    4, data 0x1de3e000, D1Rual) 'vg_spath'
[   9] 0x1de3e060: used   96 (refcount 1 lock count 0, size       20, align    4, data 0x1de3e080, d0RUal) 'VG_PATH_T.coords'
0x1de3e0c0: free 32
[   5] 0x1de3e0e0: used   96 (refcount 1 lock count 0, size        5, align    1, data 0x1de3e100, d0RUal) 'VG_PATH_T.segments'
[ 207] 0x1de3e140: used 1.6M (refcount 2 lock count 8, size  1658880, align 4096, data 0x1de3f000, d1Rual) 'KHRN_IMAGE_T.storage'
[ 430] 0x1dfd4160: used 1.6M (refcount 1 lock count 0, size  1658880, align 4096, data 0x1dfd5000, d1Rual) 'KHRN_IMAGE_T.storage'
[ 426] 0x1e16a180: used 1.6M (refcount 2 lock count 1, size  1658880, align 4096, data 0x1e16b000, d1Rual) 'KHRN_IMAGE_T.storage'
[  81] 0x1e3001a0: used  192 (refcount 2 lock count 0, size      116, align    4, data 0x1e3001c0, d0rual) 'EGL_SERVER_SURFACE_T'
[ 517] 0x1e300260: used  992 (refcount 3 lock count 0, size      924, align    4, data 0x1e300280, d0rual) 'VG_SERVER_STATE_T'
[ 382] 0x1e300640: used 2.1K (refcount 1 lock count 0, size     2048, align    4, data 0x1e300660, d0rual) 'KHRN_MAP_T.storage'
[ 367] 0x1e300e80: used   64 (refcount 1 lock count 0, size        0, align   32, data 0x1e300ea0, d3ruAl) 'khdispatch_readahead'
[ 213] 0x1e300ec0: used 1.0M (refcount 1 lock count 0, size  1048576, align   32, data 0x1e300ee0, d3ruAl) 'khdispatch_workspace'
[ 301] 0x1e400f00: used   96 (refcount 1 lock count 0, size       22, align    1, data 0x1e400f20, d1rual) 'khrn_hw_null_render'
[ 168] 0x1e400f60: used  160 (refcount 1 lock count 0, size       96, align    4, data 0x1e400f80, d0rual) 'KHRN_MAP_64_T.storage'
[  50] 0x1e401000: used  576 (refcount 1 lock count 0, size      512, align    4, data 0x1e401020, d0rual) 'KHRN_MAP_T.storage'
[ 300] 0x1e401240: used 1.1K (refcount 1 lock count 0, size     1024, align    4, data 0x1e401260, d0rual) 'KHRN_PID_MAP_T.storage'
[ 395] 0x1e401680: used  576 (refcount 1 lock count 0, size      512, align    4, data 0x1e4016a0, d0rual) 'KHRN_MAP_T.storage'
[ 573] 0x1e4018c0: used  576 (refcount 1 lock count 0, size      512, align    4, data 0x1e4018e0, d0rual) 'KHRN_MAP_T.storage'
[ 512] 0x1e401b00: used  576 (refcount 1 lock count 0, size      512, align    4, data 0x1e401b20, d0rual) 'KHRN_MAP_T.storage'
[ 278] 0x1e401d40: used  576 (refcount 1 lock count 0, size      512, align    4, data 0x1e401d60, d0rual) 'ILCS VC buffer pool'
[   3] 0x1e401f80: used 8.0M (refcount 1 lock count 8, size  8355840, align 4096, data 0x1e402000, d3rual) 'ARM FB'
[   2] 0x1ebfafa0: used  16K (refcount 1 lock count 0, size    16384, align   32, data 0x1ebfafc0, d0ruAl) 'audioplus_tmp_buf'
[   1] 0x1ebfefe0: used 4.0K (refcount 1 lock count 0, size        0, align 4096, data 0x1ebff000, d1rual) 'camera fast alloc arena'
small allocs not requested
How can I avoid such behaviour?
This is happening of latest stable raspbian with kernel 4.9.77 and firmware version 334597236bcc2498b0a044e21aa2f5b255bf3d22 (clean) (release)

Return to “Graphics programming”

Who is online

Users browsing this forum: No registered users and 4 guests