[Lazarus] Challenge of converting a Delphi project

Mattias Gärtner nc-gaertnma at netcologne.de
Wed May 5 13:46:15 CEST 2010


Zitat von Juha Manninen <juha.manninen at phnet.fi>:

> José Mejuto wrote:
>> Had you tried to use heaptrc to detect memory corruption ? There is
>> also a more agressive heaptrc option that do not reuse memory blocks
>> that could be very good in this case but needs heaptrc recompilation.
>
> I must admit I never used heaptrc before. Now I did. There is even a switch
> for it in project settings.
> The program still raises an exception when writing to TRegistry  
> (uses XML file
> under Linux). The error listing below comes after just opening and closing
> EssModel. If I also create a diagram with EssModel, the listing is much
> longer.
> How to interpret it? Where is the actual error?



> I also get strange hints when compiling the project. They basically say that
> none of the project units were used, while they certainly are.

The units are not used in the lpr file. The Delphi IDE (mis)uses the  
dpr file as project file. The Lazarus IDE hides these hints.


> Would you care to take a look at the project?
>
> Regards,
> Juha
>
> ---------------------- Compiler hints : -----------------------
>
> essmodel.lpr(38,39) Hint: Unit "uListeners" not used in EssModel
> [...Delphi IDE special...]
> ---------------------- heaptrc errors : ----------------------
>
> [DBGTGT] TApplication.HandleException Failed to set data for value
> "RecentFiles"
> [DBGTGT]   Stack trace:
> [DBGTGT]   $08274418
> [DBGTGT]   $0827488D
> [DBGTGT]   $080A86FF line 144 of System/uconfig.pas

Here is your error that raises an exception.
Wrong access to the registry.


> [DBGTGT]   $0808F3B7 line 188 of System/umainform.pas
> [DBGTGT]   $080816F8 line 868 of include/customform.inc
> [DBGTGT]   $0807FDDHeap dump by heaptrc unit

The exception is not handled properly and the code fails to clean up.  
(Missing try..finally). Each is listed by heaptrc.


> [DBGTGT] 8638 memory blocks allocated : 706318/727880
> [DBGTGT] 8611 memory blocks freed     : 705662/727152
> [DBGTGT] 27 unfreed memory blocks : 656

27 memory allocations were not freed. It should be 0.


> [DBGTGT] True heap size : 458752
> [DBGTGT] True free heap : 455920
> [DBGTGT] Should be : 456296

For example a timer:

> [DBGTGT] Call trace for block $B51E3C60 size 48
> [DBGTGT]   $081E4152 line 90 of qtobject.inc
> [DBGTGT]   $08148754 line 135 of customtimer.pas
> [DBGTGT]   $08148900 line 212 of customtimer.pas
> [DBGTGT]   $080BEBFB line 88 of System/ufeedback.pas
> [DBGTGT]   $08148885 line 181 of customtimer.pas
> [DBGTGT]   $081487EF line 156 of customtimer.pas
> [DBGTGT]   $0825C60C line 3875 of qtobjects.pas
> [DBGTGT]   $B7F40C7E
> ...and so forth ...
> [DBGTGT] exception at 08274418:
> [DBGTGT] Failed to set data for value "RecentFiles".
> [DBGTGT]  81 of essmodel.lpr
> [DBGTGT]   $B7C67ACE
> [DBGTGT]   $0823965F line 218 of imagelistcache.pas
> [DBGTGT] Call trace for block $B7FC9FA0 size 16
> [DBGTGT]   $080BECBF line 112 of System/ufeedback.pas
> [DBGTGT]   $0806F564
> [DBGTGT]   $B7C67ACE

Beware the line info is not always reliable.

Mattias






More information about the Lazarus mailing list