Help with "Out of Memory" Error

Started by Scorpio82, Mon 08/11/2010 00:18:34

Previous topic - Next topic

Scorpio82

I've been beta-testing some of the last few rooms in my game, all very heavy in characters, puzzles, graphics and dialogue, and while I managed to get it all playable, I've just run into a new problem where this started coming up:

QuoteError: Out of memory: failed to allocate 768000 bytes (at PP=4300)

Followed by a game crash.

I figured it might be due to the graphic-heavy nature of my game, but when I tried playing it from the very beginning (which wasn't as graphic heavy,) I discovered the same thing would happen after some extended play.  I opened my Task Manager and sure enough, my game file was accumulating memory - never dumping it, even if I stood around doing nothing - and would always crash around 1,700,000 KB.

This error reminded me of all the memory game crashes I used to get with the old Sierra games (like KQ6.)  I was wondering if there was a work-around in AGS so that the RAM doesn't stockpile the game's memory to the pointing of crashing.

I'm currently running AGS v3.1.2 SP1 on Windows XP with 3.25 GB of RAM.



Wyz

Sounds like a memory leak. Easiest way to get one is if you use Dynamic sprites and never delete them. If this was the case AGS should produce errors in the log file though.
Life is like an adventure without the pixel hunts.

Khris


Calin Leafshade

Well I'm fairly sure AGS has automatic garbage collection so there much be some huge dynamic sprite arrays or something.

i.e the dynamic sprites must still have pointers referencing them

Scorpio82

Thanks for the quick replies.

While I've been working on my game for a long time, the concept of dynamic-anythings is still new to me.  Looking through the help files, it doesn't seem like I intentionally made any dynamic sprites or arrays - unless a dynamic sprite refers to a large transparent animated object in the background.  Otherwise, everything I put in my game is either put in as a cCharacter or oObject, and I can't see any of it taking up 2 gigs of RAM.

The biggest chunk of memory in my game comes from a scene that involves multiple objects - all background-sized and animated with a bit of transparency thrown in.  It's for environmental and puzzle-related purposes - but when the animations start, I can see the memory usage in the task manager jumping up by 10 megs every second. 

If I minimize the game, it all drops back down to zero, so now I'm wondering if there's a way I could clear the cache without requiring the player to minimize their game every few minutes.

Scorpio82

I've been researching my problem, and came up with a simple fix for one problem.  In my Advanced Setup options, I set the RAM size to 100, and it somehow stopped my 10mb/s memory leak on a couple of scenes, so that stopped my game from crashing on those single scenes alone.

I'm still having problems with the game stockpiling memory from scene to scene.  It's like the Sprite Cache is hoarding the sprites instead of deleting them.  There's no dynamic sprites involved.  Is there anything I can do to force-flush the cache after every room?

Gilbert

Quote from: Scorpio82 on Mon 15/11/2010 08:10:43
There's no dynamic sprites involved.

Hmmm. Do you use any script modules in your game? It can also be possible that some of these modules use DynamicSprites and do not take care of them appropriately. (As far as I remember, how DynamicSprites are handled aren't explicitly explained in the manual and it seems that unlike Strings, etc., it is hinted that automatic garbage collection won't work with DynamicSprites and so you need to call Delete() whenever you have to dispose one.)

Of course, it can also be a memory leak in the engine, as you mentioned that your game is quite graphically intensive, that your game may have reached some limit that other people have not encountered yet. If the problem persists, you may try to upload the game in question and PM CJ to test it to see whether it's the engine's fault.

Pumaman

There was a bug in 3.1.2 and previous versions, where if you had a single sprite that was bigger than the size of the sprite cache (eg. a 25 MB sprite and a 20 MB sprite cache), it could get corrupt and crash like this.

This is probably the cause of your problem since increasing the sprite cache to 100 MB has fixed it for you.

As for the memory in task manager -- if it's reducing back to a normal level after you minimise the window, there's probably no problem. This can be normal, it doesn't necessarily mean that all that memory is in use but just that the system hasn't had time yet to clean up the memory.

SMF spam blocked by CleanTalk