[Lazarus] Is this a bug?
Joost van der Sluis
joost at cnoc.nl
Fri Jun 16 13:27:13 CEST 2017
On 06/16/2017 11:43 AM, Wolf via Lazarus wrote:
> If I understand you correctly, because
> 2. since ParamStr() is handled by the system unit, a call to halt will
> result in a memory leak because Heaptrc is not aware of this allocation.
Only the initialization of the system-unit is done before the
heap-manager is in place. So this is no issue.
The memory being allocated for the commandline and it's parameters
itself is system-specific. If there is any memory allocated at all.
> If this is correct, then the conclusion has to be that Heaptrc cannot be
> trusted as a debugging tool because it is ill-informed about what the
> system unit is up to.
Heaptrace is a great debugging-tool. Debugging-tools give you more
information to help you find problems. But they can never be trusted.
The same holds for any debugger, btw.
The part about the system-unit is incorrect. (See above)
Calling Halt(), is, well... dangerous. On the other hand you should not
care about memory-leaks on application exit. But I can imagine that it
obfuscates things when you are searching for real memory-leaks.
Try to place your code in a 'try .. finally' block, and call Halt()
thereafter. Of even better, in a procedure, and halt after the
procedure-call. You have probably problems with implicit try-finally
sections, as Mattias pointed out. You can also investigate this by
looking at the created assembly. (fpc -an)
Regards,
Joost.
> wolf (rather disillusioned)
>
> On 16/06/17 20:47, Mattias Gaertner via Lazarus wrote:
>> On Fri, 16 Jun 2017 20:36:54 +1200
>> Wolf via Lazarus <lazarus at lists.lazarus-ide.org> wrote:
>>
>>> Now I am nicely confused: If halt does call finalization sections, isn't
>>> then all heap space requested by the system unit supposed to be freed as
>>> well?
>> The system unit is special. It is loaded even before the heap manager
>> is initialized. Heaptrc does not report memory of the system unit.
>>
>> Heaptrc reports allocations after its initialization, which is
>> usually right after the system unit.
>>
>>
>> Mattias
>
More information about the Lazarus
mailing list