PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Suggestions: Threads, Signals, Disposable mem, etc

ChezDoodles · 21 Apr 2006, 08:03 UTC
Using Edge for a test game, I immediately had to add quite a bit of functionality before I could start building a game.

Even though Egde is an excellent product, I would still like to suggest a few additions to the library - in order to keep the client source platform independant:

API for spinning off threads, creating and accessing signals and critical sections.

API for doing block memory allocations that don't grow the heap. During Suspend / Resume it is natural to dispose certain large resources - like bitmaps - to free up memory for the OS and other applications. Just deleting memory objects in EdgeLib don't necessarily free physical memory (due to fragmentation it might even be impossible to do) - but with a seperate memory allocation api for large blocks, I could do allocations outside of the heap - like VirtualAlloc / VirtualFree in Windows.

Thanks for a great product!
Thanks for your suggestions, we will look into this.

Maybe you can post a piece of sample code?
ChezDoodles · 23 Apr 2006, 08:32 UTC — Disposable memory objects
A Win32 version would probably look something like this:


Code:
void* ClassEMemory::AllocDisposable( U32 iMemSize )
{
void* pMemBlock;
pMemBlock = ::VirtualAlloc( NULL,
iMemSize,
MEM_COMMIT,
PAGE_READWRITE );
return pMemBlock;
}

void ClassEMemory::DeAllocDisposable( void* pMemBlock )
{
::VirtualFree( pMemBlock,
0,
MEM_RELEASE );
}


Note:
Memory allocated through this interface is not supposed to replace regular Alloc/DeAlloc's. To to multiple small memory allocs of disposable memory, your should rather alloc a large chunk of disposable memory and implement your own sub-allocation scheme.
Code:
Alright, that sounds quite easy.
It may be a good idea to keep allocating small and large blocks of disposable memory in the same function (and check for the block size internally). Do you have a certain treshold which determines if the block of disposable memory is too small to allocate at once?

So far I haven't found a similar function for Symbian (I've found the RHeap class, but I assume this works the same as the heap on Windows).
ChezDoodles · 24 Apr 2006, 08:15 UTC
Personally, I alloc one large block of disposable memory and perform sub-allocation within that block myself. But having Edgelib automatically alloc disposable memory if the block size is above - lets say 100k - would be great!