Thread View: comp.lang.c++.leda
3 messages
3 total messages
Started by P. Mantecon
Fri, 18 Aug 1995 09:06
LEDA's Memory management
Author: P. Mantecon
Date: Fri, 18 Aug 1995 09:06
Date: Fri, 18 Aug 1995 09:06
14 lines
937 bytes
937 bytes
As we all know, LEDA includes the macro LEDA_MEMORY(type) to provide an efficient memory management schema. Basically it allocates memory in chunks of 2^13 -4 bytes and then slices every chunk in cells of the appropriate size. I can understand the size of the basic chunk to be a power of 2, but what puzzles me is that -4 bytes, so my question is the following: why the chunk size is precisely 2^13-4 instead of being just 2^13? Ideas, anyone? Patricia P.S. Source code appears in _memory.c & memory.h
Re: LEDA's Memory management
Author: Frank Muzzulini
Date: Fri, 18 Aug 1995 16:36
Date: Fri, 18 Aug 1995 16:36
17 lines
1284 bytes
1284 bytes
P. Mantecon (pmanteco@haifa.cern.ch) wrote: > I can understand the size of the basic chunk to be a power of 2, but > what puzzles me is that -4 bytes, so my question is the following: > why the chunk size is precisely 2^13-4 instead of being just 2^13? malloc() always needs some additional bytes to store some information about the allocated block. If you 'malloc' exactly 8k, it has to allocate one block more, than needed to store 8k. Seems to me, that's why they spare out the 4 bytes. Muzz -- ___ Frank Muzzulini ua0y@rz.uni-karlsruhe.de Muzz@irc <*,*> ... until the colour of a man skin is of no more [`-'] significance than the colour of his eyes ... Bob Marley (War) -"-"-
Re: LEDA's Memory management
Author: Heribert Dahms
Date: Fri, 18 Aug 1995 20:25
Date: Fri, 18 Aug 1995 20:25
22 lines
1818 bytes
1818 bytes
In <412fhq$j98@nz12.rz.uni-karlsruhe.de> ua0y@rzstud1.rz.uni-karlsruhe.de (Frank Muzzulini) writes: : P. Mantecon (pmanteco@haifa.cern.ch) wrote: : > I can understand the size of the basic chunk to be a power of 2, but : > what puzzles me is that -4 bytes, so my question is the following: : > why the chunk size is precisely 2^13-4 instead of being just 2^13? : : malloc() always needs some additional bytes to store some information : about the allocated block. If you 'malloc' exactly 8k, it has to : allocate one block more, than needed to store 8k. : Seems to me, that's why they spare out the 4 bytes. If I remember right, this space is for some sort of next pointer from LEDA, not malloc(), and we had to hack around to increase this from 4 to 8, because OSF/1 on DEC Alpha uses 64bit pointers. BTW, <8Kb for data structures is a severe limit nowadays; that's not a PDP11. (Now I prefer Tcl/Tk, where I can easily have a single string of several Megabytes... (If someone doesn't now what Tcl/Tk is, see the comp.lang.tcl FAQ)) Bye, Heribert (dahms@ifk20.mach.uni-karlsruhe.de)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads