Pampers man, Pampers

So I’ve decided that I hate memory leaks. I hate ’em. I hate them like Indy hates snakes. This hate stems from a cute coincidence. I had the foresight of making ThiefEd and the Engine pull from the same information, just so long as it is saved. The pictures are all the same and the collision bits are all the same. So when I make a change in ThiefEd and save it, it shows up in the Engine as soon as I walk off screen and come back. This, combined with the cute window trick I learned, made it quite easy to play with the Editor and the game and really help make each screen a little nicer to play.
Everything was ducky, but the Engine would start to get slower and slower. Eventually it would make the rest of the computer go slow too. So I had to pull the plug and take a hit of the CAD (not the comic. I find the comic boring. I’m talking about the Key Command – which I find thrilling.) and like I try to do, have a look at the processes. So there was the Engine. It was eating 245000 kB, or 250 MB or a quarter of a GIG of my Ram. In effect, the Engine had somehow managed to eat no less than 1/2 of all of the memory in my laptop – in about 7 minutes. Clearly, steps had to be taken.
A test was in order. So, I went into the code and put little breaks in with little commands to let me know where the break was. Then I fired up the CAD menu (I don’t think that’s what it is really called, but I don’t care) and watched the memory usage. Once it hopped up, I checked the last break that I let run and went to stare at it.
By the way, watching the screen build itself in pieces is kinda cool.
Anyhow, the issue was with my enemy Streaming technique. You see, I had this idea – I was going to use the same variables for all of the enemy crap. Their attacks animations would all have a standard call and they would be set by the enemy type and the frame of the attack, and they would be loaded right before I needed them. I was really trying to avoid having lots and lots of specific variables, like I have for Zero. Each of his little frames has a variable handle and is loaded when the program starts. I had considered doing a similar stream for him, but after this – forget it. Either way, the system worked, but it seemed that every time any of the enemy animations was streamed, it would copy the whole thing to memory in a brand new place and forget about the last one. Mind you, it didn’t remove the information, it just forgot that it left it there. This of course makes it impossible for the computer to use. The computer looks at that and says to itself, “Hmm, something’s using this. Well, guess I’ll go use different memory.” Or to put it another way. It’s like I have a field for picnics, and I tell Robo – the Super Robo Computer – to go put a blanket someplace. Then I tell it, “You know what, how about we put a different color down instead?” Then Robo finds a different color blanket and puts it down without picking up the first one. Generally, not a problem. It’s a big field after all and can have lots and lots of blankets. When you make the same mistake a couple thousand times, you can’t see the grass anymore.
But wait, there’s more! I couldn’t just tell the thing to erase them as soon as I drew them of course, since I had referenced them in other stuff too. If I deleted it, then the program would get confused. “Hey Robo,” I say, “go pick up that blanket and eat it. Great.” “Hey Robo,” I continue, “what color and how big is the blanket?” “What blanket?” Robo replies. I by ‘replies’ I mean ‘crashes’, and by Robo I mean the Program.
So, like I said before. I hate memory leaks. I hate ’em.
Which brings me to my next point – Pampers. “Pampers” is a n3rd term that I’m going to try and popularize. It is used thusly: “Yeah, debugged that. Now the code is totally Pampers.” or “I feel a lot safer knowing this submarine is Pampers.” It means, that there are no leaks. No leaks is good.
***After 6 hours, my Engine is now Pampers***
Even better. When it idles with Zero just standing around, it cleans itself up and begins to use less memory. So:


-Oh, and one more thing. I still don’t come up on Yahoo search when I type in “Confessions of an Indie Developer.” Not that I care all that much – since this is the Diary That Nobody Reads, but I do like to be able to find my own crap. So from here on out, Yahoo is dead to me. Yeah, I said it.
-On a side note, I’m 3rd now when I look for Indie Confessions or “Confessions of an Indie Developer” (with or without quotes) on Google. To celebrate this achievement, I’ve added another clicky box for adverts. Then took it down because it was tacky.

Leave a Reply

Your email address will not be published. Required fields are marked *