Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2016-03

Access violation in an empty project declaring heaptrc

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog

Hello,

Just create a project like this:

program project1;
{$mode objfpc}{$H+}
uses heaptrc;
begin
end.

Now, compile and try to run that, you will get this error:

Heap dump by heaptrc unit
0 memory blocks allocated : 0/0
0 memory blocks freed : 0/0
0 unfreed memory blocks : 0
True heap size : 131072 (1856 used in System startup) True free heap : 129216
An unhandled exception occurred at $770E8E19:
EAccessViolation: Access violation
$770E8E19
$770E8D28
$0040A8C9
$0040A456
$00413BC2

Why an access violation in an empty project, is it a heaptrc bug?

Now, if you compile and run this project below with -gh:

program project1;
{$mode objfpc}{$H+}
begin
end.

You will get:

Heap dump by heaptrc unit
47 memory blocks allocated : 1173/1280
47 memory blocks freed : 1173/1280
0 unfreed memory blocks : 0
True heap size : 163840 (112 used in System startup) True free heap : 163728

What means "112 used in System startup"? I have a project that in some cases I get:

Heap dump by heaptrc unit
90 memory blocks allocated : 2827/3072
90 memory blocks freed : 2827/3072
0 unfreed memory blocks : 0
True heap size : 196608
True free heap : 196480
Should be : 196608

So it seems that the "Should be : 196608" in this case is related to the 128 used in the system startup, because when I comment all the code in this project I get "128 used in System startup".

Silvio Clécio

Reply by email

Sven Barth
to silvioprog
"silvioprog" wrote 19 lines
Now, if you compile and run this project below with -gh: program project1; {$mode objfpc}{$H+} begin end. You will get: Heap dump by heaptrc unit 47 memory blocks allocated : 1173/1280 47 memory blocks freed : 1173/1280 0 unfreed memory blocks : 0 True heap size : 163840 (112 used in System startup) True free heap : 163728 What means "112 used in System startup"? I have a project that in some

cases I get:

Show quoted text 10 lines
Heap dump by heaptrc unit 90 memory blocks allocated : 2827/3072 90 memory blocks freed : 2827/3072 0 unfreed memory blocks : 0 True heap size : 196608 True free heap : 196480 Should be : 196608 So it seems that the "Should be : 196608" in this case is related to the

128 used in the system startup, because when I comment all the code in this project I get "128 used in System startup".

That is the memory that had been used before the memory manager of the heaptrc unit had been setup. Remember that there's first the System unit initialization and only then the initialization of the heaptrc unit.

Regards,
Sven

Reply by email

silvioprog
to Sven Barth

On Thu, Mar 3, 2016 at 4:05 AM, Sven Barth
wrote:
[...]

That is the memory that had been used before the memory manager of the heaptrc unit had been setup. Remember that there's first the System unit initialization and only then the initialization of the heaptrc unit.

Indeed. About the AV, I'm not sure if it is related to #29558 <http://bugs.freepascal.org/view.php?id=29558>, because it happens even with a empty project just declaring the heap unit.

Silvio Clécio

Reply by email