Re: Heap fragmentation due to LoadImage function.
"Raghavendra Naik" <someone@microsoft.com> ha scritto nel messaggio
news:fpgrmp$qsi$1@daniel-new.mch.sbs.de...
I have an application where I am loading a large number of bitmaps using
LoadImage function.
When I did a memory profiling of the application I observed that there
was lot of memory fragmentation due to this API.
You may try to put several images into the *same* bitmap, and load a single
bitmap containing several different images.
Then you can define "regions" (e.g. rectangular regions, using RECT
structure), inside your loaded bitmap, and extract (e.g. blitting) single
images contained in that bitmap.
<ascii art fixed-font>
+------+------+------+
| img1 | img2 | ... |
+------+------+------+
| ... ... ... |
.. . . .
.. . . .
+------+------+------+
| | | imgN |
+------+------+------+
</ascii art fixed-font>
For example, with DirectDraw in the past I put several frames of an
animation in the same bitmap, then only one bitmap was loaded (not several
bitmaps, one for each frame, just one bitmap containing *all* the frames for
given animation), and I blittled the desidered frame extracting it from the
only bitmap.
This may help you reduce heap fragmentation (in fact, you will call
::LoadImage only once, or few times, but not 1000 times).
HTH,
Giovanni