On Fri, Mar 13, 2015 at 3:13 AM, Matthias Schmitt <freak002 at mmp.lu> wrote:
>> On 12 Mar 2015, at 17:35, Richard Hipp <drh at sqlite.org> wrote:
>>
>> Let's start with the basics:  How do you know that the memory was in
>> fact leaked and is not instead simply being held for reuse?
>
> The Xcode development environment comes with a debugging tool named 
> ?Instruments? which is able to detect memory leaks quite reliable. It traces 
> all references to code segments. If a reference to a code segment is 
> overwritten with a new value, but the previously addressed memory segment was 
> not released, then the software detects this as a leak. The same thing is 
> true when a variable created inside a code block references allocated memory. 
> When the program leaves the code block without releasing the previously 
> allocated memory, the reference get inaccessible and the allocated memory 
> cannot be released any more.

By default SQLite stores database pages by allocating space for the
page plus space for metadata after the page, and then passes around
references to that metadata.  This can mislead tools of this sort,
because the reference is to a point well within the allocation rather
than to the actual allocation.  You might experiment with
SQLITE_PCACHE_SEPARATE_HEADER to see if that changes the results.

-scott

Reply via email to