Based some some ideas here
http://chdk.setepontos.com/index.php?topic=5929.0 I've come up with an alternate way to get memory in CHDK.
Changset 1015This is very experimental. I've booted the camera, taken a picture, a few seconds of video, and run a couple lua scripts, but that's it. Possible risks and side effects are unknown.
This is controlled by the compile time option OPT_EXMEM_MALLOC
To use this, you must also find the function I called _exmem_alloc and add it to stubs_entry_2.S This function can be found on recent cameras by finding ExMem.AllocCacheable, and finding the first real (more than a few instructions) function that calls.
This only affects regular malloc currently, umalloc still comes from the original pool. You can set the amount of memory used in wrappers.c. You can also set which ExMem pool is used there. How much memory you can allocate isn't clear. I ran it up to 16mb, and the camera booted, but I didn't really do any testing. The default is current 2mb, which is ~2x larger than any normal CHDK camera has.
This will only work on dryos without additional hacking.
The lua script attached will record ExMem info to EXMEMINF.LOG. Native calls must be enabled.
edit:
Big thanx to mx3, the sub-allocator he found for the elf branch was just what I needed.