James Dennett wrote:
-----Original Message-----
From: John Stanton [mailto:[EMAIL PROTECTED]
Sent: Monday, November 19, 2007 12:14 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Memory Usage
Dynamic allocation is not the problem, it is malloc and free. there
is
a difference between being certain and being lucky.
Could/would you expand on that? There's limited difference between
malloc/free and other dynamic allocation systems, and I'm assuming that
we're not considering transparent garbage-collection as an option.
What about malloc/free do you claim is problematic, and why is it not
problematic with other dynamic allocation approaches? Do you speak of a
problem with the interface, or with specific implementations?
-- James
Malloc is a concept implemented in various ways, some more successful
than others but all of them hidden from the programmer. Free tries to
give back memory but as you can appreciate unless you use some garbage
collection scheme with backwards pointers fragmentation and
checkerboarding is very difficult to avoid.
If you allocate memory directly and have your program reuse it in a way
which cannot fragment you achieve dynamic memory allocation which is
truly reversible.
When you think carefully about the memory usage in your program you can
often use the stack rather than the heap and avoid problems. Local
memory on the stack never fragments.
Various OS's have ways of allocating memory under control of the virtual
memory manager so that it is not in the heap and can be completely
returned. For example it can be an anonymous shared file. If the
machine has a disk, using virtual memory when suitable will avoid a heap
overflow and crash, but be aware that you can have the situation where
it will perform a lazy write through to disk.
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------