Sign in Join

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

Mailing lists / fpc-devel / 2009-11

heaptrc

14 messages · 7 people ·

Reply by email Subscribe to this list Your subscription

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

JoshyFun

Hello FPC,

The Graeme's comment about heaptrace bring me some questions about it that were "lost in my pocket".

(Windows only I think, and I do not know if Lazarus exclusive)

Is there any way to only show the heaptrace window when leaks are present ?
Is there any way to add a cancel button to the window that show leaks ?

With 1000 leaks is not funny to press the OK button around 300 times. I know I can cancel the program, but a cancel button seems to be more clean.

If this message is more a Lazarus related problem, please let me know. Thank you.

Best regards, JoshyFun

Reply by email

Mattias Gaertner
to JoshyFun
Show quoted text 15 lines
Hello FPC, The Graeme's comment about heaptrace bring me some questions about it that were "lost in my pocket". (Windows only I think, and I do not know if Lazarus exclusive) Is there any way to only show the heaptrace window when leaks are present ? Is there any way to add a cancel button to the window that show leaks ? With 1000 leaks is not funny to press the OK button around 300 times. I know I can cancel the program, but a cancel button seems to be more clean.

I guess these are todos.

If this message is more a Lazarus related problem, please let me know. Thank you.

Yes, it is more lazarus related.

Mattias

Reply by email

Vincent Snijders
to Mattias Gaertner
Mattias Gaertner wrote 21 lines
On Thu, 19 Nov 2009 10:53:09 +0100 JoshyFun wrote: > Hello FPC, > > The Graeme's comment about heaptrace bring me some questions about it > that were "lost in my pocket". > > (Windows only I think, and I do not know if Lazarus exclusive) > > Is there any way to only show the heaptrace window when leaks are > present ? > Is there any way to add a cancel button to the window that show leaks > ? > > With 1000 leaks is not funny to press the OK button around 300 times. > I know I can cancel the program, but a cancel button seems to be more > clean. I guess these are todos.

I am not so sure. Heaptrc outputs to stdout. If the application is compiled -WG the RTL redirects the output to message windows. I would recommend to let heatprc write to file. See http://www.freepascal.org/docs-html/rtl/heaptrc/environment.html and/or http://www.freepascal.org/docs-html/rtl/heaptrc/setheaptraceoutput.html

> If this message is more a Lazarus related problem, please let me know. > Thank you. Yes, it is more lazarus related.

I disagree. Any GUI application with heaptrace has the same issue.

OTOH, if the output is redirected to file, Lazarus has a nice view: leakview, a ide plug-in you can find in lazarus\components\leakview

Vincent

Reply by email

Graeme Geldenhuys
to JoshyFun: The Graeme's comment about heaptrace bring me some questions about it that were "lost in…
JoshyFun wrote 5 lines
(Windows only I think, and I do not know if Lazarus exclusive) Is there any way to add a cancel button to the window that show leaks ?

It's not specific to Lazarus or Windows. As Vincent said, rather output to file using an environment variable. The heaptrc documentation explains it all.

The 'leakview' Lazarus add-on is also a good option - I've used it a few times before.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email

JoshyFun
to Vincent Snijders: I am not so sure. Heaptrc outputs to stdout. If the application is compiled -WG the RTL…

Hello Vincent,

Thursday, November 19, 2009, 11:36:31 AM, you wrote:

VS> I am not so sure. Heaptrc outputs to stdout. If the VS> application is compiled -WG the
VS> RTL redirects the output to message windows. I would VS> recommend to let heatprc write
VS> to file. See
VS> http://www.freepascal.org/docs-html/rtl/heaptrc/environment.html VS> and/or
VS> http://www.freepascal.org/docs-html/rtl/heaptrc/setheaptraceoutput.html

I'm currently redirecting to file but 2 problems, file is not erased on each run and in the development process and test you must manually open the file to know if something leaks (easy to forget).

VS> I disagree. Any GUI application with heaptrace has the same issue. VS> OTOH, if the output is redirected to file, Lazarus has a nice view: leakview, a ide VS> plug-in you can find in lazarus\components\leakview

LeakView does not report right runs, only bad runs, and also you must open it on each run. Anyway this "bug" must be Lazarus related.

Best regards, JoshyFun

Reply by email

Graeme Geldenhuys
to JoshyFun
JoshyFun wrote
on each run and in the development process and test you must manually open the file to know if something leaks (easy to forget).

Under any unix-type environment do the following in a console window... Simply keep this console window open in one corner of your screen.

  $ tail -f <heaptrc_output_filename>
eg:
  $ tail -f /tmp/heaptrc.txt

This will now continuously show you the output of heaptrc.

Alternatively, always execute your applications from the command line and simply let heaptrc output to stdout. On application exit you will get a summary output and if memory leaks occured, the need information for the leaks.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email

Luiz Americo Pereira Camara
to Graeme Geldenhuys: It's not specific to Lazarus or Windows. As Vincent said, rather output to file using an…
Graeme Geldenhuys wrote 13 lines
JoshyFun wrote: > (Windows only I think, and I do not know if Lazarus exclusive) > > Is there any way to add a cancel button to the window that show leaks > ? > It's not specific to Lazarus or Windows. As Vincent said, rather output to file using an environment variable. The heaptrc documentation explains it all.

A better solution would be implement some kind of callback in heaptrc that could be hooked by the application to intercept and decide when and how to show. This could allow LCL applications to show e.g. a window with the leakview control instead of the std message window.

Luiz

Reply by email

Martin
to Luiz Americo Pereira Camara
Luiz Americo Pereira Camara wrote 17 lines
Graeme Geldenhuys escreveu: > JoshyFun wrote: > >> (Windows only I think, and I do not know if Lazarus exclusive) >> >> Is there any way to add a cancel button to the window that show leaks >> ? >> > It's not specific to Lazarus or Windows. As Vincent said, rather output > to file using an environment variable. The heaptrc documentation > explains it all. A better solution would be implement some kind of callback in heaptrc that could be hooked by the application to intercept and decide when and how to show. This could allow LCL applications to show e.g. a window with the leakview control instead of the std message window.

If you use a hook, to put the heptrc window in place, then the whole thing would run in the user app => put an instance of the heaptrc window in the uswer app can not control the ide to jump anywhere => so no use.

IMHO the IDE should by default set the enviromane so the heaptrc gets written to a file in the project dir (which is cleared by the IDE before). Then the IDE can pick it up...

Reply by email

Vincent Snijders
to Martin
Martin wrote
IMHO the IDE should by default set the enviromane so the heaptrc gets written to a file in the project dir (which is cleared by the IDE before). Then the IDE can pick it up...

Nice idea, if only the bug in gdb (on windows) to set environment variables in the debuggee would be fixed...

Vincent

Reply by email

Vincent Snijders
to Jonas Maebe
Jonas Maebe wrote 5 lines
On 19 Nov 2009, at 20:31, Vincent Snijders wrote: > Nice idea, if only the bug in gdb (on windows) to set environment variables in the debuggee would be fixed... Where's the gdb bug report? I can't find it.

Where should it be reported?

How should report it?

Vincent

Reply by email

Jonas Maebe
to Vincent Snijders
Vincent Snijders wrote 6 lines
Jonas Maebe schreef: > On 19 Nov 2009, at 20:31, Vincent Snijders wrote: >> Nice idea, if only the bug in gdb (on windows) to set environment variables in the debuggee would be fixed... > Where's the gdb bug report? I can't find it. Where should it be reported?

http://sourceware.org/bugzilla/ (google: report gdb bug)

How should report it?

Using a reproducible case described step by step, similar to an FPC bug report. Bonus points if you can provide a C program to reproduce it. If you only have an FPC program, it's best to include also a compiled version so that people interested in looking it at don't have to install FPC first (although it's possible that Pierre will be the one looking at that report).

Jonas

Reply by email

Vincent Snijders
to Jonas Maebe
Jonas Maebe wrote 14 lines
On 19 Nov 2009, at 20:42, Vincent Snijders wrote: > Jonas Maebe schreef: >> On 19 Nov 2009, at 20:31, Vincent Snijders wrote: >>> Nice idea, if only the bug in gdb (on windows) to set environment variables in the debuggee would be fixed... >> Where's the gdb bug report? I can't find it. > Where should it be reported? http://sourceware.org/bugzilla/ (google: report gdb bug) > How should report it? Using a reproducible case described step by step, similar to an FPC bug report. Bonus points if you can provide a C program to reproduce it. If you only have an FPC program, it's best to include also a compiled version so that people interested in looking it at don't have to install FPC first (although it's possible that Pierre will be the one looking at that report).

I tried, but I am not capable of writing the c program: http://sourceware.org/bugzilla/show_bug.cgi?id=10989

Vincent

Reply by email

JoshyFun
to Vincent Snijders

Hello Vincent,

you wrote 6 lines
> Using a reproducible case described step by step, similar to an > FPC bug report. Bonus points if you can provide a C program to > reproduce it. If you only have an FPC program, it's best to include > also a compiled version so that people interested in looking it at > don't have to install FPC first (although it's possible that Pierre > will be the one looking at that report).

VS> I tried, but I am not capable of writing the c program: VS> http://sourceware.org/bugzilla/show_bug.cgi?id=10989

Well, I think is quite easy to demonstrate:

------------------------------------
gdb.exe C:\Windows\System32\cmd.exe
set environment GDBTEST=1
r
[...]
C:\>set [enter]
------------------------------------

Or even more strange:

------------------------------------
gdb.exe
file C:/windows/system32/cmd.exe
r
Program exited with code 01.
------------------------------------

Or maybe I missunderstood the "file" command means ?

Best regards, JoshyFun

Reply by email