I have a lottery game I wrote in dx9, mostly vb.net, some c#. For the most part it went really well once I got ahold of Tom Millers MDX Kickstart, but recently I ran into some memory problems. Apparently if I leave the game running long enough it will run out of memory. Not entirely surprising, but the behavior of Device.AvailableTextureMemory that I ran into trying to track down my memory leak is.
The first step I took trying to figure this out was of course to keep an eye on the texture memory. I counted all the textures that get loaded and unloaded when entering / exiting a state, so far so good. However I noticed that just playing the game the availabletexturememory does go down during playing despite the fact that no textures are loaded during play.
Now I know texture memory on the video card and ram are linked, but heres the strange part: The drops in available memory seem to coincide with the first time an individual texture is drawn for the first time. As mentioned this is a lottery game, so for instance when you pick your numbers initially the memory drops, the first time any of them are "hit", goes down a little bit more. As you may imagine at first it drops quite rapidly and then slows down as you come closer to all of them having been drawn. Presumably it would eventually stop.
Is this what its supposed to do? I'm really lost because that makes it rather hard to figure my actual memory requirements, and also I cant seem to find a way to release the memory (when they switch back to the "cashier" screen for example) Perhaps I'm just doing something stupid, so I'll post a bit of code at the bottom, but if anyone can shed any light on this I'd be very appreciative. Sorry for the long post but want to be as clear as possible.
Protected Shared HitTexture(74) as direct3d.texture
Protected Shared PickedTexture(74) as direct3d.texture
Protected Shared CalledTexture(74) as direct3d.texture
Select Case Me.State
Case LotterNumberState.Hit
MyBase.Draw(HitTexture(Me.Value - 1))
Case LotteryNumberState.Called
MyBase.Draw(CalledTexture(Me.Value - 1))
Case LotteryNumberState.Picked
MyBase.Draw(PickedTexture(Me.Value - 1))
End Select
Overridable Sub Draw(ByRef spriteTexture As Direct3D.Texture)
If Visible Then Sprite.Draw(spriteTexture, Me.Size, BlankVector3,
Position, Color.White)
End Sub