Tim Rühsen wrote on 2019-12-29: > >> As a more general approach, a function that switches already allocated > >> memory into read-only memory would be handy. Like in > >> - m = malloc() > >> - initialize m with some data > >> - if in debug mode: call memmap_readonly(m) - from this point on 'm' is > >> read-only and a write leads to a segmentation fault. > >> - ... > >> - free(m) > > > > Hardware has write barriers only on the page level. You can't easily request > > a write barrier for a requence of, say, 30 bytes. To accomodate this, the > > API needs to have a certain shape. Paul wrote: > > True, and it means that immalloc() always allocate multiples of the page > size (page is 4096 bytes on x86_64 ?). How do you plan to optimize > memory usage here ?
I optimized the memory usage by allocated several small or medium sized objects in a single memory page. Through the module 'ssfmalloc'. Bruno