Memory usage (freeimage) 2
Blitz3D Forums/Blitz3D Beginners Area/Memory usage (freeimage) 2
| ||
Hello! Some time ago i created topic (http://www.blitzbasic.com/Community/posts.php?topic=98842) about "strange" freeimage working. But today, i see something strange again :) and i'm confused. Yasha wrote in previous topic: <<<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? >>> Well, memory usage increase and not stop. (i used Process Explorer, and default windows Task Manager) tasks: 1. load image data 2. decode data 3. load image 4. free image. if you run a cycle (0...n) of these points, then memory usage will continue to increase... Process Explorer (start program): Private Bytes: 34556K Working Set: 19244K (after 1500 loop repeat): Private Bytes: 61576K Working Set: 46600K +loop again: more... more... more... memory usage, up to 100+ MB RAM and more again... I hope this is my last topic about it :) but i want to clarify just in case: is it OK for windows too or...? :) P.S. Sorry for my English. image data: http://rghost.ru/download/41085413/12e31f88fa53374e9f1520dd2ab0ed3a6e77e2ea/menu.dat test-unit: ;--------------------------------------------------------------------------------------------- Global nsl_form_menu ;--------------------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------------------- Graphics 640,480,16,2 SetBuffer BackBuffer() ;--------------------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------------------- While Not KeyHit(1) Cls If KeyHit(57) ;space ;For k = 0 To 3000 ;Cls If order = 0 ; load_graphic() ; order = 1 Else FreeImage nsl_form_menu order = 0 End If ;Text 10,10,k ;Flip ;Next End If ;If order = 1 ; DrawImage nsl_form_menu,30,30 ; Text 5,5,"image loaded" ;Else ; Text 5,5,"no image" ;End If Flip Wend ;--------------------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------------------- Function load_graphic() im_order = 1 For k = 1 To 1 Select True ; Case im_order = 1 im_handler$ = "menu.dat" ; decrypt_graphic(im_handler$) ; ;handler: nsl_form_menu = LoadImage("image.bin") ; DeleteFile ("image.bin") ;Case im_order = ... ; ; End Select im_order = im_order + 1 Next End Function ;--------------------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------------------- Function decrypt_graphic(im_handler$) ;put image to temp bank: file = OpenFile(im_handler$) size = FileSize(im_handler$) bank = CreateBank(size) ReadBytes bank,file,0,size CloseFile file ;decrypt file: For k = 0 To size - 4 Step 4 value = (255 - PeekByte(bank,k)) PokeByte bank,k,value Next ;put image to temp file: file = WriteFile("image.bin") WriteBytes bank,file,0,size CloseFile file FreeBank bank End Function |
| ||
This example actually runs with constant memory use on my system, according to Task Manager. Perhaps the problem is in some of the code you cut...? |
| ||
Yasha, i'm sorry! This is my fault. this is not "bug". In this time everything is ok. My brain is exploded....) |