[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: immutable string type
From: |
Bruno Haible |
Subject: |
Re: immutable string type |
Date: |
Mon, 18 Jan 2021 09:17:27 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-197-generic; KDE/5.18.0; x86_64; ; ) |
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: immutable string type,
Bruno Haible <=