Use umm_malloc for Lua to reduce memory fragmentation
Rather than letting Lua allocate a few thousands of tiny blocks with ML memory backend (which is slow, and memory fragmentation may cause Canon code to fail), in this experiment I tried pre-allocating a 512KB block and using umm_malloc on it.
What doesn't fit here (e.g. if you have some more scripts) is allocated with default ML routines.
Besides reduced fragmentation, scripts are loaded quite a bit faster now.
Disadvantages:
- even if you have only a tiny script, this will allocate 512K.
- on some cameras, this block may be from shoot_malloc, and there are some disadvantages with that (for example, in-camera raw development, or enabling certain image processing options, may fail with err70, because they expect the shoot_malloc buffer to be completely free - probably to change the memory management profile or whatever). Of course, that is true for any other memory-intensive module, until we find some other allocator that can be kept allocated without Canon code complaining about it.
Any suggestion for a memory allocator (external library) that can grow at runtime, as needed?