Ever increasing VidMem usage
Blitz3D Forums/Blitz3D Programming/Ever increasing VidMem usage
| ||
I'm working out VidMem used simply as TotalVidMem() - AvailVidMem() and despite my best effort I can't stop it from always increasing. I'm freeing textures when they're not required and deleting entities when they're done with and as far as I can tell this is all happening correctly, but still the VidMem usage keeps going up. Is this normal with Blitz or am I missing something in my code? |
| ||
Check for missing UnlockBuffer commands. |
| ||
Just checked - they're all Unlocked. |
| ||
Are you playing mpg or avi? There is a definite memory leak each time they loop - found by me, confirmed by a few people, unreplied to by Blitz Support. |
| ||
Memory leak in movies??? Oh not good! i was going to use them! Thanks for the heads up! freetextures arn't enough, besure your freeing entities your not using too! simply making the "pointer" setting that to 0 wont work. |
| ||
Nope, no movie files. And I'm freeing entities too. As it looks like this isn't normal then I presume I've just missed one somewhere. I'll have another look. |
| ||
Its a long shot, but I had a similar problem. I went through my code line by line, and still had the same problem. Then I updated my graphics card driver and since then no problems. Might be worth a shot? Cheers, Unc |
| ||
It's happening on both my PCs and they both have different gfx cards (one is a Geforce 4, the other an Intel thingumywotsit). |
| ||
Memory leak in movies??? Oh not good! i was going to use them! It all depends. If it's a one-shot movie intro, that's probably ok, but if it loops then each time it will chew the memory equivalent roughly to the file size. There appears to be no way to Free(the memory of) a movie. It is quite a bind for me - I wanted movies on quads to simulate fire, water etc, not to mention TV. Now I've simply had to give up the idea, because even though it might take a few hours, eventually the user's machine/app will lock. |
| ||
Okay, I think I've tracked it down. I'm using Syntax Error's Sprite Control code for pixel-perfect quad sprites. Sprites are loaded with the following Sprite Control function:Function LoadImage3D(Filename$, Masked = True, texflags=4, Parent=-1, RetainAlpha=False) ; Create quad mesh If Parent = -1 Parent = SpritePivot Local sprite=CreateMesh(Parent) Local s=CreateSurface(sprite) AddVertex s,0,0,0 ,0,0 : AddVertex s,2,0,0 , 1,0 AddVertex s,0,-2,0 ,0,1 : AddVertex s,2,-2,0 , 1,1 AddTriangle s,0,1,2 : AddTriangle s,3,2,1 ; transfer image into texture buffer (with alpha) Local tmpimage=LoadImage(Filename$) Local spritetexture=LoadTexture(Filename$,texflags) Local iw=ImageWidth(tmpimage) , ih=ImageHeight(tmpimage) Local tw=TextureWidth(spritetexture) , th=TextureHeight(spritetexture) If Not RetainAlpha Then If iw<>tw Or ih<>th ib=ImageBuffer(tmpimage) LockBuffer(ib) tb=TextureBuffer(spritetexture) LockBuffer(tb) For x=0 To iw-1 For y=0 To ih-1 rgbc=ReadPixelFast(x,y,ib) And $00ffffff If rgbc=((r Shl 16)+(g Shl 8)+b) And Masked ; ALB - added And Masked WritePixelFast x,y,($00000000),tb Else WritePixelFast x,y,(rgbc Or $ff000000),tb EndIf Next Next UnlockBuffer(ib) UnlockBuffer(tb) EndIf End If FreeImage tmpimage ; Texture and resize sprite. Move handle to top/left ScaleTexture spritetexture,Float(tw)/Float(iw),Float(th)/Float(ih) EntityTexture sprite,spritetexture FreeTexture spritetexture EntityFX sprite,1+16 EntityOrder sprite,-100 ScaleEntity sprite,Float(iw)/2,Float(ih)/2,1 PositionEntity sprite,-10000,-10000,0 Return sprite End Function and free'd with Function FreeImage3D(Sprite) Local brush = GetEntityBrush(Sprite) Local tex = GetBrushTexture(brush) If brush <> 0 FreeBrush brush If tex <> 0 FreeTexture tex If Sprite <> 0 FreeEntity Sprite End Function But FreeImage3D doesn't seem to actually release the Vid Mem, it just keeps going up. These Sprite Control functions are wrapped in my own code, but they don't really add much - eg. my delete sprite function is just: Function DeleteSprite(Sprite.Sprite) If Sprite <> Null Then FreeImage3D(Sprite\SpriteControlID) Delete Sprite End If End Function Any ideas why FreeImage3D wouldn't be freeing up Vid Memory? |
| ||
It's a long shot but try freeing the texture before the brush. |
| ||
Nah, didn't help. Is Blitz perhaps optimising things by just releasing textures but not actually freeing vid mem until it has to? |
| ||
According to the docs 'GetEntityBrush' and 'GetEntityTexture' actually create a new brush and a new texture so it would appear you aren't actually deleting the brush/texture applied to the sprite, only copies of them. Is that what the docs mean? If so you would have to store a handle to the actual texture+brush then delete them if no other sprites are using them. If not then I'm just being very confused O.o |
| ||
It appears that that might be the case. In which case, how do I actually delete the entity's texture? What I'm finding confusing is that freeing the textures used by Planes and Terrains (which I use for backgrounds) works fine and frees up the vid mem they were using, but doing it for these quads doesn't seem to work. |
| ||
There is a definite memory leak each time they loop - found by me, confirmed by a few people, unreplied to by Blitz Support When was that? |
| ||
When was that? http://www.blitzbasic.com/Community/posts.php?topic=46958&hl=leak I gotta tell you, the number one thing putting me off BlitzMax is the way you keep "disappearing" continuing problems (FMOD anyone?) into the "Bug Bin", as if they were resolved. Doesn't exactly inspire confidence. |
| ||
Thanks, Sledge. I didn't want to say that, coz I love Blitz3D, Mark Sibly, and Blitz Support with a passion. But this vid loop memory leak does make the use of video pretty well unusable, especially if you expect to leave it running in front of a customer (as in TV display, billboard display). |
| ||
I didn't want to say that, coz I love Blitz3D, Mark Sibly, and Blitz Support with a passion. You're their customer, not the other way around. If something doesn't work properly, you're allowed to complain... ...and they'll duly ignore you completely. :) |
| ||
Hopefully that one was missed by BRL by accident. I remember when the bug bin was created a LOT of random stuff went in there straight away, so this one may have slipped in there without them knowing. |