Kriss@xxxxxxxx wrote: > As far as I can tell the problem is just that android is not letting me > allocate any memory close enough to the location I want, when the range was > double it works first time. I think it's just a coincidence that it worked. It looks like regular memory allocations and the space for shared libraries are drawn from the same linear address pool. Due to the high virtual memory pressure in your app, all gaps around the shared library will eventually be filled. An easy way to work around this would be prelinking the shared library to a specific address far away from everything else. Alas, Android deprecated prelinking with 4.x due to security concerns and finally disabled it in 4.2. Playing with the ELF virtual load address doesn't work, because Bionic doesn't permit a non-zero image base address for shared libraries. The only workaround I can think of (without rewriting the dynamic linker) would be to mmap() a huge block of virtual memory with PROT_NONE, then load the LuaJIT shared library and munmap() the block right after that. That should put the shared library out of reach of the memory allocator. --Mike