mcedit issues

Roland Illig roland.illig at gmx.de
Fri Nov 5 14:57:50 UTC 2004


Andrew V. Samoilov wrote:
> Also as far as I remember glib 1.2 allocates initially 1K memory area on default
> and doubles this area each time to fit string.  I am using LiveCD and
> embeded distros on low memory machines with specially stripped mc,
> so I dont glad to see this memory allocation strategy.

Yes, you're correct. I just checked glib-1.2, too.

We can argue about which strategy of allocation (glib, strcats() or 
n*strlen + m) is better/worse, but I don't think it makes much 
difference. Additionally, the string is freed in the same function call, 
so it is really temporary.

I wrote a little test program for the glib-1.2 memory usage. You should 
not use glib-1.2 at all if your memory is limited.

break = 0x8049924 (init)
break = 0x806b000 (after g_malloc)
break = 0x806a000 (after g_free)
break = 0x806a000 (after g_string_new)
break = 0x806a000 (after g_string_free)

Here you see that glib allocates quite much memory, and that it does not 
matter if we use GString or not.

Roland
-------------- next part --------------
A non-text attachment was scrubbed...
Name: glibtest.c
Type: text/x-csrc
Size: 437 bytes
Desc: not available
URL: <http://lists.midnight-commander.org/pipermail/mc-devel/attachments/20041105/3ca3f82a/attachment.c>


More information about the mc-devel mailing list