Custom memory allocator question. | developer.brewmp.com Custom memory allocator question. | developer.brewmp.com

Developer

Custom memory allocator question.

Forums:

Hi all,
I've written my own cross platform (BREW / Symbian at the moment) memory allocator. The allocation / free code is called from globally overloaded new / delete. So my question is, if new / delete can get called from anywhere, how can I get back to accessing my own pre-allocated memory without global variables? Is using GETAPPINSTANCE() in BREW and "thread local storage" on Symbian the way to go?

If anyone sugests just calling MALLOC / FREE from new and delete I may just throttle them ;)

Thanks,

Steve.

Yes, GETAPPINSTANCE should work for BREW. You can either pass around your allocator pointer to your each classes, or call to GETAPPINSTANCE to get global module pointer, from which you can retrieve your allocator pointer.
As far I know there are issues with using overloaded new/delete in Symbian. You may not be able to overload new/delete for CBase class, from which many of your class may derive.

Yes, GETAPPINSTANCE should work for BREW. You can either pass around your allocator pointer to your each classes, or call to GETAPPINSTANCE to get global module pointer, from which you can retrieve your allocator pointer.
As far I know there are issues with using overloaded new/delete in Symbian. You may not be able to overload new/delete for CBase class, from which many of your class may derive.

Using GETAPPINSTANCE() is certainly your most elegant and cleanest way to do it, yes.

Using GETAPPINSTANCE() is certainly your most elegant and cleanest way to do it, yes.

Hi Ruben/Dragon,
Is there any way for me to use custom memory allocator in a BREW extension? The problem is that GETAPPINSTANCE returns the running applet, which I don't define.
Thanks,
Jian

Hi Ruben/Dragon,
Is there any way for me to use custom memory allocator in a BREW extension? The problem is that GETAPPINSTANCE returns the running applet, which I don't define.
Thanks,
Jian

If you are using extension, you can still use custom memory allocator, you need to pass around your allocator pointer (most recommended), or you can use GetTLS in BREW 2.x in BREW 3.1 GetALS is recommended solution.

If you are using extension, you can still use custom memory allocator, you need to pass around your allocator pointer (most recommended), or you can use GetTLS in BREW 2.x in BREW 3.1 GetALS is recommended solution.