3 ms·
You just have to override the new operator (C++) or use a different malloc (C). All you need is to replace brk() with an appropriate mmap(). Don't know how it g
by xxxyy 12y ago
You just have to override the new operator (C++) or use a different malloc (C). All you need is to replace brk() with an appropriate mmap(). Don't know how it goes for Rust.
C++ is especially appealing, because you can embed file-backed mmap allocations in chosen classes by overriding their new operator. So you could for example create a float array class that automagically allocates itself in a file-backed mmap region by a simple new Array() call.
Edit: Python's numpy has a file-backed array:
http://docs.scipy.org/doc/numpy/reference/generated/numpy.memmap.html http://docs.scipy.org/doc/numpy/reference/generated/numpy.me...
- amelius 12y agowell, the problem is that the mmapped file is based at a different address every time you mmap it. (in realistic situations, and the general case) thus, every pointer dereference needs a base address. how is the support for this?
- xxxyy 12y agoThis is not an easy way to serialize objects, it is merely a way to help virtual memory manager recognize portions of memory that can be saved to disk in the first place. .so files are loaded through mmap, and the pointers problem is solved there through the mechanism of relocations. But please don't write raw memory objects to disk, use Google Protobuf or ASN.1