• Advertisement
Sign in to follow this  

Using 'new' and 'delete' on proper games consoles

This topic is 4853 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was just wondering if anyone knew how 'new' and 'delete' would work on (proper) games consoles. I say 'proper' because I am not including things like PS2 Linux. I mean consoles in which you have direct access to the physical memory of the machine. It's just that I know that even on certain modern consoles, you have to declare and manage a heap yourself (even if the manufacturer provides libraries that can do this, you still have to use those libraries). I'd be grateful if anyone with console programming experience would explain how heap management happens on these machines and how does this affect the development of multi-platform games? Cheers

Share this post


Link to post
Share on other sites
Advertisement
I have no real experience, so take this with a grain of salt, but I'm doubtful that it's quite as bad as you imaging on all consoles. Remember that Xbox, for instance, is very similar to a computer. I'm sure it would have good memory management.

Share this post


Link to post
Share on other sites
For other similiar environments (I've never programmed consoles specifically) like embedded pc's or use of C++ in an OS kernel what you typically do is override global new and delete to do whatever it is you have to do.

You still end up managing the heap yourself but it still looks like plain ol' C++.

Share this post


Link to post
Share on other sites
It's not so shockingly different as you might think. For any specific platform, you pretty much know what the address range available for use is, but global new and delete are implemented in the CRT that comes with the C++ compiler for that platform, so you can just allocate yourself a big chunk of memory (just under 32 Mb on PS2 for example) and then use a custom memory manager to slice that into chunks upon request. Whether that's through overridden new/delete operators or your own allocator interface, it's not really that critical.

One reason to to use a custom memory manager is so you have a high level of control over the allocation strategies taken to keep fragmentation to a minimum. When you only have 16 Mb (plus a high latency 8 Mb) on Gamecube, for example, you need just about every byte you can salvage. Another is to add your own logging and metrics functionality to help you find memory-hogging code and memory leaks, and maybe add some bounds-checking code to help detect any scribbler bugs. There's probably more reasons too, if you spend some time thinking about it.

Share this post


Link to post
Share on other sites
From what I gather, there's a stong leaning on consoles to write your own memory manager because of the severely restricted amountof memory that is available. The PS2, iirc, only gives you a total of 32 MB of RAM; you have to manage that carefully.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
well xbox gives you 64 mb (i believe its shared memory though between cpu gpu and spu?(sound)) and additionally, xbox has virtual memory, but of course a memory manager would probably still be advantagous because we all know how fast the page file is :-D

-Dan

Share this post


Link to post
Share on other sites
new and delete are functions of the run-time library designed to interact either with an OS or directly with the hardware in some cases. new and delete are not neccesarily more platform spacific in the console realm as, say, between PCs, MACs and SUN workstations. Different platforms I'm sure have differing levels of support.

cross-platform developers are likely using the common libraries provided the console companies for things like new and delete (they are C++ features, after all) and probably have in-house libraries for things such as memory managers which are syntactically equivilant across platforms.

Share this post


Link to post
Share on other sites
All the major consoles include memory management as part of the operating system. All have compilers that support malloc/free and new/delete.

Share this post


Link to post
Share on other sites
new and delete are just c++ functions that calls malloc and free, AND also calls the constructor/destructor. Nothing fancy at all.
We used one memory-manager for both PS2 and xbox (actually PC as well.. for ppl without devstations ;]), overloading the global new and delete functions (and malloc and those functions as well). The only thing we didn't use our memory manager for was D3D:s own allocations (D3D on the xbox uses low-level memory functions).
The only thing really different between the memory-maneger for PS2 and xbox version was the functions to get a callstack for each allocation.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement