Blit and memory leak ??

Blitz3D Forums/Blitz3D Programming/Blit and memory leak ??

Filax(Posted 2004) [#1]
Graphics3D 640,480,16,2
SetBuffer BackBuffer()

Print "Before : "+AvailVidMem ()
MyImage=LoadImage("test.jpg")
DrawImage MyImage,0,30

FreeImage MyIMage
Print "After : "+AvailVidMem ()

WaitKey

If i try this program i don't obtain the same result about my memory ?? why ??


D4NM4N(Posted 2004) [#2]
tried it and it seemed ok on my machine. mabe it could be due to a background programs running causing the mem to fluctuate.


antero(Posted 2004) [#3]
I have the same problem :

win2k - sp4 (all updates)
geforce fx 5200
512 Ram
PIV 3000

avg antivirus free edition
sygate personal firewall


Ross C(Posted 2004) [#4]
Maybe blitz doesn't visiably free up the memory till it's actually needed?


Koriolis(Posted 2004) [#5]
I have no problem here.
It could just be due to differences in the way video memory is handled, for different gfx drivers. It's quite possible that ther is some "lazy" memory managing behind the scene.

It might be better to try to load dozens of big distinct images and see if the unfreed memory is always proportional to the number of loaded images. Just to see if memory is still unfreed even when the vram starts to be saturated. If so, then there's really something wrong happening.


Gabriel(Posted 2004) [#6]
Doesn't happen here, and I tried it fullscreen, windowed, debug on, debug off, the values are always the same.


antero(Posted 2004) [#7]
well here sometimes it happens others it doesn't ... its random :) my favorite kind of bug ( I wish )


Eole(Posted 2004) [#8]
I have the problem too


D4NM4N(Posted 2004) [#9]
have you got a memory monitoring program (like the taskmonitor does for RAM) that draws a time graph (mabe you could write your own), to see what the state of the memory is before you run the program, you will be able to see if its unstable.
(you will have to use windowed mode tho)


BlackD(Posted 2004) [#10]
Modified the code for a createimage blitz test. Values return to normal after image is freed here.

Graphics3D 640,480,16,2 
SetBuffer BackBuffer() 
Print "Before : "+AvailVidMem () 
MyImage=CreateImage( 500,500)
Print "During : "+AvailVidMem () 
DrawImage MyImage,0,30 
FreeImage MyIMage 
Print "After  : "+AvailVidMem () 
WaitKey 
Flax - using this code, does the memory return to normal? If this works (frees the memory correctly) and your code doesn't, then its likely a Blitz issue (as the processes being passed to the video card are the same) and should be reported.


smilertoo(Posted 2004) [#11]
try running it in a loop to see if its just delaying the freeing of memory until theres a big chunk to free.


BlackD(Posted 2004) [#12]
Code to do what john suggested above. Try different values of I, but don't go too high. ;) Them be large images. It'll start consuming virtual memory and give a false result. That test should use about 51 megs of video memory so as long as you have at least a 64 meg card it should work fine.

Graphics3D 640,480,16,2
SetBuffer BackBuffer() 
Type image
    Field pic
    End Type
MemBefore = AvailVidMem () 
For I = 1 To 50
    test.image = New image
    test\pic = CreateImage(500,500)
    DrawImage test\pic,0,0 
    Next
MemDuring = AvailVidMem () 
For test.image = Each image
    FreeImage test\pic
    Delete test
    Next
Print "Starting Memory:       "+MemBefore
Print "After creating Images: "+MemDuring
Print "After freeing Images : "+AvailVidMem () 
WaitKey
+BlackD

edit: Actually, I've noticed a pattern emerging. All the people who have the problem are from europe. Do they sell dodgy video cards there or something. ;)


Filax(Posted 2004) [#13]
It's strange i don"t obtaint the same number ?? i have a GEForce FX
card.


BlackD(Posted 2004) [#14]
Which FX card are you using? Which brand? See if other people with the same card have the same problem.

Alternatively, if you have a spare video card lying around in a drawer or something, try putting it in and see if that problem still happens, or if its just a conflict with your current card/drivers. If it still happens with a different card, but doesn't happen on someone elses system, then theres something else in your system causing the problem. Using memory managers? Leaked drivers? Old DirectX runtimes? Win2k/ME/XP? Etc. Easy way to find a fault - eliminate everything that's not causing it.

+BlackD