Author Topic: Something is eating my heap!!  (Read 1700 times)

0 Members and 1 Guest are viewing this topic.

Offline Doan Sephim

Something is eating my heap!!
« on: May 12, 2007, 10:42:16 PM »
I actually know exactly what is "eating" my heap...and when I say "eating" I mean that the game is losing heap space every game cycle and when I switch rooms the heap does not reset as it should. Some heap is simply MIA!! Restarting the game restores the heap, but that would probably be expected.

Here is what I am doing. I have a region that I am accessing. In the region's doit method I have this:
Code: [Select]
(= myEvent Event:new(evNULL))The above code is what is "eating" the heap.
I am then using the "myEvent" x and y values to have certain actions happen when the cursor is simply in a certain area, so there are two probable ways to solve my problem...either determine why the code is leaking heap or use a different way to achieve the same goal...either way I would be happy with ;)

However the myEvent code (which I found in Cloudee1's aquarius game) for some reason munches away on heap space. I assume it wasn't a problem in Cloudee1's game as I never had the heap space run out...might it have something to do with my using it in a region??
« Last Edit: May 12, 2007, 10:54:07 PM by Doan Sephim »


Artificial Intelligence Competition

Offline troflip

Re: Something is eating my heap!!
« Reply #1 on: May 12, 2007, 11:08:30 PM »
Well, you're creating a new Event object on the heap every game cycle and never deleting it.

So you need to delete it right after you're done using it:
Code: [Select]
(send myEvent:dispose())




Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Doan Sephim

Re: Something is eating my heap!!
« Reply #2 on: May 12, 2007, 11:53:42 PM »
Hey thanks! That works perfect! This kinda stuff always happens when I don't REALLY know how something works and I just copy and paste!

Thanks for clarifying what exactly I was doing! I feel stupid when I post questions and there is only ONE small snippet of code that solves all the problems...lol.

BTW...thanks a ton Troflip for those more advanced tutorials! They have served me quite well lately! I never EVER would've figured out quite how to use regions without those tutorials.
« Last Edit: May 12, 2007, 11:56:51 PM by Doan Sephim »
Artificial Intelligence Competition

Offline troflip

Re: Something is eating my heap!!
« Reply #3 on: May 13, 2007, 07:27:56 PM »
Yeah, you hardly ever need to think about memory management if you just do "normal" stuff with the template game.  For example if you do the "View:new()addToPic()" thing, you don't need to do anything special, because the View adds itself to a global list of objects that automatically gets disposed of when you change rooms.

But not so with most other things that you :new()

Glad the tutorials help  :)


Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline lskovlun

Re: Something is eating my heap!!
« Reply #4 on: May 14, 2007, 11:47:48 AM »
There's also another thing you could do. Instantiate an Event object like
Code: [Select]
(instance myEvent of Event
 (properties))

Then in your main code, say:
Code: [Select]
GetEvent(evNULL myEvent)

This way, you don't need to allocate/deallocate memory all the time.


SMF 2.0.14 | SMF © 2017, Simple Machines
Simple Audio Video Embedder

Page created in 0.107 seconds with 24 queries.