Sign in Join

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

Mailing lists / fpc-devel / 2002-09

Improvements for heaptrc.pp

11 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

Mattias Gaertner

Hi,

Here are some suggestions to improve heaptrc.pp.

1. getmem_cnt, freemem_cnt, getmem_size, freemem_size, getmem8_size, freemem8_size should be readable via functions in the interface. Very useful for optimization.

2. QuickTrace = false is very slow, but also very useful. It would be nice to have a procedure, that can be called at any time, and that does a big check. For example:

procedure CheckHeap;
var p: pointer;
begin
  QuickTrace:=false;
  GetMem(p,4);
  FreeMem(p);
  QuickTrace:=true;
end;

3. Move QuickTrace into the interface part.

Mattias Gaertner

Reply by email

Peter Vreman
Show quoted text 5 lines
Hi, Here are some suggestions to improve heaptrc.pp. 1. getmem_cnt, freemem_cnt, getmem_size, freemem_size, getmem8_size, freemem8_size

should
be readable via functions in the interface. Very useful for optimization.

2. QuickTrace = false is very slow, but also very useful. It would be nice to have a

procedure, that can be called at any time, and that does a big check. For example:

Show quoted text 11 lines
procedure CheckHeap; var p: pointer; begin QuickTrace:=false; GetMem(p,4); FreeMem(p); QuickTrace:=true; end; 3. Move QuickTrace into the interface part.

The quicktrace improvement can only be done for the heaptrc available in 1.1. That version supports extra information that can have different sizes

Reply by email

Lee, John

So could we use these functions to get the compiler to state its memory useage for each unit? J

Here are some suggestions to improve heaptrc.pp.

1. getmem_cnt, freemem_cnt, getmem_size, freemem_size, getmem8_size, freemem8_size should be readable via functions in the interface. Very useful for optimization.

This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.

Reply by email

Mattias Gaertner
to Peter Vreman: should be readable via functions in the interface. Very useful for optimization.…
GMT Peter Vreman wrote 19 lines
> Here are some suggestions to improve heaptrc.pp. > > 1. getmem_cnt, freemem_cnt, getmem_size, freemem_size, getmem8_size, freemem8_size should be readable via functions in the interface. Very useful for optimization. > > 2. QuickTrace = false is very slow, but also very useful. It would be nice to have a procedure, that can be called at any time, and that does a big check. For example: > > procedure CheckHeap; > var p: pointer; > begin > QuickTrace:=false; > GetMem(p,4); > FreeMem(p); > QuickTrace:=true; > end; > > 3. Move QuickTrace into the interface part.

Sorry, the 3. is nonsense. It is already in the interface.

The quicktrace improvement can only be done for the heaptrc available in 1.1. That version supports extra information that can have different sizes

How is this related?
The quicktrace flag is just for checking the whole heap. I used it, and it seems to work very nice.

Mattias

Reply by email

Peter Vreman
Show quoted text 27 lines
On Wed, 4 Sep 2002 12:11:51 GMT Peter Vreman wrote: > > Here are some suggestions to improve heaptrc.pp. > > > > 1. getmem_cnt, freemem_cnt, getmem_size, freemem_size, getmem8_size, freemem8_size > should > be readable via functions in the interface. Very useful for optimization. > > > > 2. QuickTrace = false is very slow, but also very useful. It would be nice to have a > procedure, that can be called at any time, and that does a big check. For example: > > > > procedure CheckHeap; > > var p: pointer; > > begin > > QuickTrace:=false; > > GetMem(p,4); > > FreeMem(p); > > QuickTrace:=true; > > end; > > > > 3. Move QuickTrace into the interface part. Sorry, the 3. is nonsense. It is already in the interface. > The quicktrace improvement can only be done for the heaptrc available in 1.1. That

version

> supports extra information that can have different sizes How is this related? The quicktrace flag is just for checking the whole heap. I used it, and it seems to work

very nice.

Sorry, i thought that it also increases the size of the backtraces.

What can be a speed improvement is to have a value that determines how often the whole heap is checked. So you can do it only once for each 10 allocations.

Also checkpointer can shall be extended with a possibility to check if the pointer is not in one of the freed memory blocks. Together with the keep_released flag it can then be used to find dangling pointers.

Reply by email

Mattias Gaertner
to Peter Vreman
GMT Peter Vreman wrote 18 lines
> > > 1. getmem_cnt, freemem_cnt, getmem_size, freemem_size, getmem8_size, freemem8_size > > should > > be readable via functions in the interface. Very useful for optimization. > > > > > > 2. QuickTrace = false is very slow, but also very useful. It would be nice to have a > > procedure, that can be called at any time, and that does a big check. For example: > > > > > > procedure CheckHeap; > > > var p: pointer; > > > begin > > > QuickTrace:=false; > > > GetMem(p,4); > > > FreeMem(p); > > > QuickTrace:=true; > > > end; What can be a speed improvement is to have a value that determines how often the whole heap is checked. So you can do it only once for each 10 allocations.

Good idea.
This Frequency should be a public variable, so it can be changed at any time. I use the CheckHeap procedure to binary search heap destructions in programs with millions of allocations. You can imagine, that each heap check costs a lot of time. But with CheckHeap, binary search and of course the speedy fpc, you can track down bugs in minutes, that would cost in other languages days to find.

Also checkpointer can shall be extended with a possibility to check if the pointer is not in one of the freed memory blocks. Together with the keep_released flag it can then be used to find dangling pointers.

:)

Who will do it?

Mattias

Reply by email

Peter Vreman
> What can be a speed improvement is to have a value that determines how > > heap is

checked. So you can do it only once for each 10 allocations.

Good idea. This Frequency should be a public variable, so it can be changed at any time. I use the CheckHeap procedure to binary search heap destructions in programs with

millions
of allocations. You can imagine, that each heap check costs a lot of time. But with CheckHeap, binary search and of course the speedy fpc, you can track down bugs in minutes, that would cost in other languages days to find.

> Also checkpointer can shall be extended with a possibility to check if the pointer is

not

Show quoted text 6 lines
> in one of the freed memory blocks. Together with the keep_released flag it can then be > used to find dangling pointers. :) Who will do it?

I'll do it, so you can continue your good work on Lazarus :)

Reply by email

Mattias Gaertner
to Peter Vreman
GMT Peter Vreman wrote 22 lines
> > What can be a speed improvement is to have a value that determines how > > heap is checked. So you can do it only once for each 10 allocations. > > Good idea. > This Frequency should be a public variable, so it can be changed at any time. > I use the CheckHeap procedure to binary search heap destructions in programs with millions of allocations. You can imagine, that each heap check costs a lot of time. But with CheckHeap, binary search and of course the speedy fpc, you can track down bugs in minutes, that would cost in other languages days to find. > > > > Also checkpointer can shall be extended with a possibility to check if the pointer is not > > in one of the freed memory blocks. Together with the keep_released flag it can then be > > used to find dangling pointers. > > :) > > Who will do it? I'll do it, so you can continue your good work on Lazarus :)

heaptrc must be improved.

I have a problem with Lazarus.
I tried lazarus with cmem and it crashed. heaptrc did not found the error, nor my memcheck, an slightly improved heaptrc, which already contains the changes I suggested. Using heaptrc with keep_released needs several minutes and then thousands of linked list error appeared, so it was useless. The reason was an object, that was freed twice. I fixed that, so Lazarus now runs with cmem. But I'm sure there is another mem corruption. I tried memprof, but it simply crashed.

So, what I need is a mem checker, that can detect double freed blocks AND that does not need keep_released, because I dont have the time and mem to run AND that reacts with a useable output.

Does someone know a solution?

Mattias

Reply by email

Jonas Maebe
to Mattias Gaertner
Mattias Gaertner wrote
So, what I need is a mem checker, that can detect double freed blocks AND that does not need keep_released, because I dont have the time and mem to run AND that reacts with a useable output.

Valgrind may work (http://developer.kde.org/~sewardj/). You have to use cmem and compile without debugging information (you can inlcude line information however), because it doesn't support all Pascal-specific stabs and crashes on them. It can also detect a lot more problems, like access to uninitialized memory locations etc. You may want to use the "sloppy malloc" option however, since other wise you'll get a lot of incorrect error reports are strcopy and friends.

Jonas

Reply by email

Mattias Gaertner
to Jonas Maebe
Show quoted text 15 lines
On vrijdag, okt 11, 2002, at 12:41 Europe/Brussels, Mattias Gaertner wrote: > So, what I need is a mem checker, that can detect double freed blocks > AND that does not need keep_released, because I dont > have the time and mem to run AND that reacts with a useable output. Valgrind may work (http://developer.kde.org/~sewardj/). You have to use cmem and compile without debugging information (you can inlcude line information however), because it doesn't support all Pascal-specific stabs and crashes on them. It can also detect a lot more problems, like access to uninitialized memory locations etc. You may want to use the "sloppy malloc" option however, since other wise you'll get a lot of incorrect error reports are strcopy and friends.

Thx.
I tried that and it gives a lot of warnings about uninitialised values in the glibc. I will try to understand that.

Mattias

Reply by email