[Portaudio] STL/ISO C++ containers?
pburk at mobileer.com
Thu Mar 24 17:41:39 EDT 2011
On 3/24/11 12:20 PM, g4 at novadsp.com wrote:
> Not that I wish to trample rose patches here :)
What does that mean?
> On 24/03/2011 18:12, Phil Burk wrote:
>> The biggest argument against it is the dynamic memory allocation. Games
>> are almost always memory constrained and you don't want to run out of
>> memory on level 19 after playing for 7 hours straight! Even if you write
>> your own memory allocator you can still run out of memory
> Sorry, just don't get this. STL is not going to 'cause' this, it does
> not allocate (or deallocate) blindly. C++ is, after all, C++, not C# nor
> Java - it is deterministic.
I realize that STL will not allocate memory unless you call certain
methods and only under certain circumstances.
> If your STL implementation is running out of
> memory then your implementation is (almost certainly) wrong.
The issue is not that STL is running out of memory. The point is that
your application may run out of memory.
On some systems the memory is limited. Game developers often push these
limits. So running out of memory is not unthinkable. Fragmentation is
also an issue, even with MMUs. The key point here is that if one is
going to run out memory it must happen predictably and as early as
possible. Then it can be discovered and fixed before the game ships. So
game designers generally allocate all their memory up front when a level
loads and avoid allocating anything during game play. This is because
game play is not deterministic. A game may be played for hours and the
possibilities are endless. The last thing they want is to get occasional
out-of-memory errors after hours of random play.
Console game developers are shipping apps that generate hundreds of
millions of dollars in revenue. They don't mess around. They often make
blanket rules like "no memory allocation after initialization". To
enforce this they sometimes require that modules do all their allocation
Now I realize that PortAudio is not supported on game consoles like PS3.
I just used the PS3 as one example of where STL might be rejected.
More information about the Portaudio