Ask a Question related to UNIX Programming, Design and Development.
-
Luiz Henrique de Figueiredo #1
persistent malloc
I'm looking for a malloc replacement that uses a persistent mmap'd file, so
that malloced data structures persist from one run to the other. I've tried
mmalloc, which comes with gdb, and it works mostly but I get some core dumps,
which don't happen when I use malloc from libc.
Does anyone have experience with mmalloc and persistency?
Is there a simpler or better alternative?
Thanks for any info.
Luiz Henrique de Figueiredo Guest
-
Persistent Shared Object not being persistent
hi my fms app maintains a persistent shared object to keep track of daily highscores, however whenever the app is reloaded or restarted all the... -
/usr/include/malloc.h:3:2: #error "<malloc.h> has been replaced by <stdlib.h>" Error code 1
Hi, if I try to build the tac_plus-4.4beta2 Tacacs Server from http://www.networkforums.net/ on my FreeBSD 5.3-RELEASE-p5 I get this Error message... -
[PHP-DEV] [PATCH] __attribute_malloc__ for malloc-like functions
> I expect the effect to be significant, though, because (as I pointed attribute((malloc)) is now enabled in CVS. Note that erealloc was... -
[PHP-DEV] [PATCH] __attribute_malloc__ for malloc-like functions
> account that every pointer in scope might be an alias of the resulting What about erealloc? It can return the same pointer as passed to it. ... -
CLI stored procedure and malloc
Hi, I'm writting a stored procedure with several mallocs in it. The first ones work fine but after a point, doing a malloc makes the procedure... -
David Schwartz #2
Re: persistent malloc
"Luiz Henrique de Figueiredo" <lhf@csgpwr1.uwaterloo.ca> wrote in message
news:bg763e$pum$1@tabloid.uwaterloo.ca...
so> I'm looking for a malloc replacement that uses a persistent mmap'd file,I don't follow. Can you be more precise about what you're trying to do.> that malloced data structures persist from one run to the other.
Decide on what data you want to save across runs, decide on a format for> Does anyone have experience with mmalloc and persistency?
> Is there a simpler or better alternative?
that data, and write it to a file. If you're using C++, store the data you
need in serializable classes.
DS
David Schwartz Guest
-
Luiz Henrique de Figueiredo #3
Re: persistent malloc
In article <bg78m7$26f$1@nntp.webmaster.com>,
David Schwartz <davids@webmaster.com> wrote:I want all my malloc'd data to be saved into a file, pointers and all, and I>
> I don't follow. Can you be more precise about what you're trying to do.
want to be able to load the file in each run and get the same data structures,
pointers and all, as in the previous run. I don't want serialization. I want
to lazy route. :-)
The mmalloc library that comes with gdb provides a malloc replacement that
uses a mmap'd file as its pool. The file persists across runs and does what I
want, expect that I get some seg faults that I don't get when using the
default malloc from the C library.
For infor on mmalloc, see [url]http://sources.redhat.com/gdb/onlinedocs/mmalloc.html[/url]
So, does anyone have experience using mmalloc for this?
Thanks.
Luiz Henrique de Figueiredo Guest
-
David Schwartz #4
Re: persistent malloc
"Luiz Henrique de Figueiredo" <lhf@csgpwr1.uwaterloo.ca> wrote in message
news:bg79je$rtb$1@tabloid.uwaterloo.ca...
> In article <bg78m7$26f$1@nntp.webmaster.com>,
> David Schwartz <davids@webmaster.com> wrote:do.> > I don't follow. Can you be more precise about what you're trying to
I> I want all my malloc'd data to be saved into a file, pointers and all, andstructures,> want to be able to load the file in each run and get the same datawant> pointers and all, as in the previous run. I don't want serialization. IThat's not really possible in principle. What if the address one of> to lazy route. :-)
those pointers points to is already in use at the time your process attempts
to attach to the file?
what I> The mmalloc library that comes with gdb provides a malloc replacement that
> uses a mmap'd file as its pool. The file persists across runs and doesI'm not surprised you get segfaults. The pointers probably don't point> want, expect that I get some seg faults that I don't get when using the
> default malloc from the C library.
to the right place in the new process.
You can make this work, but all of your pointers must be relative to the
base of the file. There are other requirements as well.
DS
David Schwartz Guest
-
Gianni Mariani #5
Re: persistent malloc
> That's not really possible in principle. What if the address one of
> those pointers points to is already in use at the time your process attempts
> to attach to the file?
>
>>>>The mmalloc library that comes with gdb provides a malloc replacement that
>>uses a mmap'd file as its pool. The file persists across runs and does
> what I
>>>>want, expect that I get some seg faults that I don't get when using the
>>default malloc from the C library.
>
> I'm not surprised you get segfaults. The pointers probably don't point
> to the right place in the new process.
>
> You can make this work, but all of your pointers must be relative to the
> base of the file. There are other requirements as well.
>
I wrote a malloc (also called MMmalloc) that has a mode were all the
pointers in the arena are offsets and can be mmapped anywhere in the
process space.
I've placed it here:
[url]http://www.mariani.ws/~gianni/MMmalloc.tar.gz[/url]
It's way old but it's easy enough to extract the interesting bits (being
how to create a relocatable arena).
G
Gianni Mariani Guest
-
James Antill #6
Re: persistent malloc
On Wed, 30 Jul 2003 02:13:02 +0000, Luiz Henrique de Figueiredo wrote:
The problem here is global variables, say you have...> In article <bg78m7$26f$1@nntp.webmaster.com>,
> David Schwartz <davids@webmaster.com> wrote:>>>
>> I don't follow. Can you be more precise about what you're trying to do.
> I want all my malloc'd data to be saved into a file, pointers and all, and I
> want to be able to load the file in each run and get the same data structures,
> pointers and all, as in the previous run. I don't want serialization. I want
> to lazy route. :-)
static struct store *beg = NULL;
static struct store *store_add(void *data);
static void store_del(struct store *store);
static struct store *store_srch(void *data);
Now everything inside the store_* API should be fine, assuming you can
easily restore the memory via. MAP_FIXED etc. However the "beg" variable
isn't known the the malloc() calls, so you need to register all
static/global variables so you can restore them (I've seen this done and
it's _far_ from the lazy route) ... As a corner case of this you could
probably use a single global and have everything else use a context that
is passed to them, but this is only feasable if almost everything already
takes a context.
Also note that in both cases you can never call anything like
gethostbyname() etc. unless you're malloc replacement has different
function names than malloc() and free().
--
James Antill -- [email]james@and.org[/email]
Need an efficent and powerful string library for C?
[url]http://www.and.org/vstr/[/url]
James Antill Guest



Reply With Quote

