Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Dec 2012 20:35 Edited at: 13th Dec 2012 20:50
One thing I've learned about programming RTS games is they use so much memory! PonyCraft uses 2.1 GB of it!

Is there a way to detect if this command fails?



I'll have to sieve through my code and optimise a few things. I think I know how to squeeze that number back down to about 1.5 GB, but geez that's still a lot.

Thanks,

TheComet

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 13th Dec 2012 21:11
OK, I've figured out why my game uses so much memory, and it's a stupid mistake I made.

Nevertheless, I'd still like the above question answered. The command will silently fail when no more memory can be allocated, but the program continues. How can I detect this? I'd still like to add the check to my game.

TheComet

The Weeping Corpse
14
Years of Service
User Offline
Joined: 19th Sep 2011
Location: United Kingdom
Posted: 14th Dec 2012 00:41
This is untested, because it's very difficult to run out of memory using a simple test program but...



Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 14th Dec 2012 02:59
Quote: "One thing I've learned about programming RTS games is they use so much memory"

I haven't noticed this.

"You're not going crazy. You're going sane in a crazy world!" ~Tick
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 16th Dec 2012 01:32
Just out of curiosity, what data are you storing in that array?
2Gb is a lot


"Why do programmers get Halloween and Christmas mixed up?"
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 16th Dec 2012 02:16
I've run into the same issues with Malevolence... You know... Infinite world and all...

The method I use is similar to what WeepingCorpse mentioned. I keep counters on everything and do checks to see if the counters are where they should be.


TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 16th Dec 2012 02:38
I was able to push it down to 300 MB now.

Most of the memory was being used by duplicate images being loaded, some memory I was also able to save by instancing props rather than cloning them. The majority of memory being used right now is from images and objects.

TheComet

Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 16th Dec 2012 12:39
Ah, I see.
It might be an idea to try to stream load media as required rather than holding it all in memory at any one time. A simple way to do this would be to load every object (images are trickier) once and hide them somewhere (you could exclude them as well) and then instance / clone them when you need another one of that particular mesh. Loading from disk in DBP unfortunately will freeze your program until it finishes loading so that is likely not desirable to do in realtime. For images I suppose you could stream them into a memblock and then make an image out of that; in that way you can read as many bytes as you want in each loop cycle until it's all loaded in.


"Why do programmers get Halloween and Christmas mixed up?"

Login to post a reply

Server time is: 2026-07-07 03:22:20
Your offset time is: 2026-07-07 03:22:20