memory usage problems

BlitzMax Forums/BlitzMax Programming/memory usage problems

Schragnasher(Posted 2008) [#1]
Ok so iv got a fairly large code base for my roguelike game right now, the thing is iv got a memory problem. My engine can push and pop gamestates onto a stack, the problem arises when doing this.

My understanding would be that if i push a new state onto the stack, then pop it off, my memory should conceivably go back to the amount before the push. (i.e. i push my main menu on top of the gameplaystate then pop it off to resume play) The push and pop seem to work just peachy, by my memory usage continues to climb as i push and pop the menu. Iv fixed some of it through my own diligence, but it still occurs.

My question is whether or not there is a good way to track down this kind of thing, and whether or not my belief is correct that the memory usage is accurate using gcmemalloced() and i should go back to my previous memory state if iv cleaned up things correctly.

Iv paired down alot of stuff i didnt need to see if i could pinpoint the problem, but its persisted, and i am to a point where the code is too interwoven to break out much more. Also iv done some reference trimming.

My debug code shows the reference count for all the objects i could and they stay constant while popping and pushing states, so i dont have a runaway from what i can tell.

Im at a loss, as its going to be open source i have no problem sending out the code or once i get a chance to update the SVN it will be at http://www.sourceforge.net/projects/simpledungeon

Any help or guidance is appreciated
Thanks
Josh b.


TaskMaster(Posted 2008) [#2]
Are you forcing a garbage collection after the pop? It may be that the GC hasn't gotten around to cleaning up yet.


Schragnasher(Posted 2008) [#3]
iv run it with a collect in the mainloop with the same problem, continually increasing memory usage, im beginning to wonder if a module im using might be the culprit in some way.


tonyg(Posted 2008) [#4]
If you have a small recreateable scenario this might help.
If your stack is on a list then try to run using just the list commands rather than any TLINK stuff.