unloading memory (freeimage)
Archives Forums/Blitz3D Bug Reports/unloading memory (freeimage)
| ||
Hello! I found some trouble in <FreeImage> operator: I trying to unload images, using Freeimage. Well, it seems strange (by task manager): win7 64 bit: start program, blitzcc.exe used - 14 Mb; after load images (big animimages) - 74 Mb; after FreeImage - 38,5...44 Mb. win7 32bit: 14 Mb - 74 Mb - 74 Mb... Where is unloading memory? :) testunit: ;------------------------------------------------------------------- ;------------------------------------------------------------------- ;------------------------------------------------------------------- Global curdir$ = CurrentDir$() Graphics 800,600,16,2 SetBuffer BackBuffer() Global limitspeed = CreateTimer(70) Global image1 Global image2 Global image3 Global load_animation Global op_menu Global animation_clock = 0 Global anim_secs = MilliSecs() Global frame ;------------------------------------------------------------------- ;------------------------------------------------------------------- While Not KeyHit(1);esc WaitTimer(limitspeed) Cls Text 10,10,"press SPACE to start\stop" If Not (MilliSecs() <= (anim_secs + 33));33 ms. animation_clock = 1 anim_secs = MilliSecs() End If ; If KeyHit(57); space button If op_menu = 1 op_menu = 0 load_animation = 0 ; FreeImage image1 FreeImage image2 FreeImage image3 Else op_menu = 1 End If End If ; If op_menu = 1 open_menu() End If animation_clock = 0 Flip Wend ;------------------------------------------------------------------- ;------------------------------------------------------------------- Function open_menu() ; If load_animation = 0 image1 = LoadAnimImage (curdir$ + "image1.png",410,172,0,30) image2 = LoadAnimImage (curdir$ + "image2.png",167,404,0,30) image3 = LoadAnimImage (curdir$ + "image3.png",200,407,0,30) load_animation = 1 End If If animation_clock = 1 frame = frame + 1 If frame = 26 Then frame = 0 End If DrawImage image2,50,23,frame DrawImage image1,185,320,frame DrawImage image3,600,30,frame End Function ;------------------------------------------------------------------- ;------------------------------------------------------------------- ;------------------------------------------------------------------- Help somebody! :) the images used (gray lines in top): ![]() ![]() ![]() |
| ||
Task Manager is not a good way to measure your program's memory use. It displays the amount of memory allocated by the system, for the whole program, not the amount of memory allocated by the program for use as objects. -- if the system is not under memory pressure, it will be relaxed about reclaiming memory that it doesn't need and may be used again in short order by your program. -- if small objects allocated by your program persist on a memory page, that entire page is lost to the system even if most of it is unused. So if you allocate huge image - tiny wrapper object - huge image - tiny wrapper object... and each pair takes up one page, then deallocate all the images, all the memory will stay in use by your program because the wrapper objects are all on separate pages. A slightly better test is to see what happens to the Task Manager figure when you reload the images. Does usage jump up to 140MB? Or does it reuse that space, indicating that the system was just being conservative? |
| ||
Thank you very much, Yasha! Yes, the memory is not increased. |