View Issue Details

IDProjectCategoryView StatusLast Update
0020526FPCRTLpublic2011-10-21 17:51
Reporterindianajones Assigned ToJonas Maebe  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionunable to reproduce 
Summary0020526: Heaptrc output not displayed when closing the application at the terminal
DescriptionAdding Heaptrc unit (-gh) doesnt effect the output of the application at the terminal output.
It works with the GTK2.


Additional InformationFPC 2.4.4
Lazarus SVN 32660
Mac OS X 10.6.8
TagsNo tags attached.
Fixed in Revision
FPCOldBugId0
FPCTarget
Attached Files

Activities

Martin Friebe

2011-10-20 13:10

manager   ~0053199

Not sure if I understand.

Where do you monitor the StdOut?

Is your application a console app, with other output to STDOUT/STDERR, or a app using forms, and you expect only the heaptrc on console? If the first, do you see the other output.

If you start your app outside Lazarus from a shell, do you see the heaptrc output then?
If so, then is the issue only, when you start your app in Lazarus using the debugger?

On GTK2 (using Laz 0.9.31) were is the heaptrc printed too?


---
General notes:
- heaptrc goes to STDERR (unless other specified, eg. you can use an env-variable to set another output, search the wiki).
- When debugging you app, the IDE instructs gdb what to do with the app output (but I am not sure if that is STDOUT only or includes STDERR).
- On linux Lazarus captures the output and shows it in the "console output" window (from "View", "debug windows"
- On MAC that is not implemented the default is /dev/null.


So the last bit could be causing your issue. you can start the app as:
yourapp >somefile #or whatever redirects STDERR

Current plan for console window on Mac is, only if someone has a patch, or detailed info how to implement it (how to create a tty that Lazarus can read).

In the global options ("Tool" menu), under debugger, you can specify a tty where the debugger should send output to. Make sure the tty exists.

indianajones

2011-10-20 14:06

reporter   ~0053201

Here is the output of the simple (GUI) application when executed from the terminal in GTK2.

indiana:~/Sources/Empty_Form$ ./project1
Heap dump by heaptrc unit
1019 memory blocks allocated : 1528391/1531280
1019 memory blocks freed : 1528391/1531280
0 unfreed memory blocks : 0
True heap size : 196608
True free heap : 196608

This doesnt work in Mac, as you commented out.
- On MAC that is not implemented the default is /dev/null.

If I understand clearly, doesnt need to create a tty, in the following example output redirected to a file and Lazarus can read from there.

indiana:~/Sources/Empty_Form$ ./project1 2>&1 | tee error.log
Heap dump by heaptrc unit
1035 memory blocks allocated : 1528839/1531792
1035 memory blocks freed : 1528839/1531792
0 unfreed memory blocks : 0
True heap size : 196608
True free heap : 196608
indiana:~/Sources/Empty_Form$ more error.log
Heap dump by heaptrc unit
1035 memory blocks allocated : 1528839/1531792
1035 memory blocks freed : 1528839/1531792
0 unfreed memory blocks : 0
True heap size : 196608
True free heap : 196608

Thanks.

Martin Friebe

2011-10-20 16:04

manager   ~0053204

Last edited: 2011-10-20 16:06

Still not clear:
- if this is an issue, when running the app outside Lazarus, or debugging in Lazarus.
- is it heaptrc only, or any console output (any STDOUT, any STDERR, or any both)

1)
"
Here is the output of the simple (GUI) application when executed from the terminal in GTK2.
"

If executed from the terminal, *outside* of Lazarus, and you do not get a heaptrc, then this is an FPC issue, and the issue needs to be moved to FPC.

2)
"
This doesnt work in Mac, as you commented out.
- On MAC that is not implemented the default is /dev/null.
"

This applies *only*, if you execute your app inside the Lazarus-IDE (Menu "Run" / green arrow), *and* "gdb" is configured as debugger.

-------
If this issue is 1 (outside Lazarus) then it must be moved to FPC.

If this is 2 (no console output on Mac) then see my previous notes. The issue description should then be changed, as it applies to all console output. Details about alternative implementations can be discussed on the mailing-list before attaching relevant notes in this report.


Is the redirect example in your post from linux or Mac or both? does the redirect work for you on Mac?

indianajones

2011-10-20 16:36

reporter   ~0053208

Yes, if executed from terminal then doesnt get a heaptrc.
The redirect example in my post is Linux only. Mac redirect doesnt work.

Jonas Maebe

2011-10-21 13:27

manager   ~0053234

> Yes, if executed from terminal then doesnt get a heaptrc.
> The redirect example in my post is Linux only. Mac redirect doesnt work.

It works fine here:


$ ./lazheaptrc
Heap dump by heaptrc unit
1729 memory blocks allocated : 1901775/1907056
1729 memory blocks freed : 1901775/1907056
0 unfreed memory blocks : 0
True heap size : 884736 (32 used in System startup)
True free heap : 887952
Should be : 884704

$ uname -a
Darwin bigmac 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:57:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_PPC Power Macintosh

This a project compiled with FPC 2.6.0rc1, but nothing has changed regarding the output handling.

Note that if you start a GUI program from the Finder in Mac OS X (or ), all of its stdout/stderr output will be redirected to /var/log/system.log. There is nothing we can do about that.

Jonas Maebe

2011-10-21 14:27

manager   ~0053238

And also:


$ ./lazheaptrc > tt 2>tt2
$ cat tt
$ cat tt2
Heap dump by heaptrc unit
1729 memory blocks allocated : 1901775/1907056
1729 memory blocks freed : 1901775/1907056
0 unfreed memory blocks : 0
True heap size : 884736 (32 used in System startup)
True free heap : 887952
Should be : 884704

Issue History

Date Modified Username Field Change
2011-10-20 10:10 indianajones New Issue
2011-10-20 10:10 indianajones Status new => assigned
2011-10-20 10:10 indianajones Assigned To => Marc Weustink
2011-10-20 10:10 indianajones Widgetset => Carbon
2011-10-20 13:10 Martin Friebe Note Added: 0053199
2011-10-20 14:06 indianajones Note Added: 0053201
2011-10-20 16:04 Martin Friebe Note Added: 0053204
2011-10-20 16:06 Martin Friebe Note Edited: 0053204
2011-10-20 16:36 indianajones Note Added: 0053208
2011-10-20 17:22 Martin Friebe LazTarget => -
2011-10-20 17:22 Martin Friebe Assigned To Marc Weustink =>
2011-10-20 17:22 Martin Friebe Status assigned => new
2011-10-20 17:23 Martin Friebe Project Lazarus => FPC
2011-10-21 13:27 Jonas Maebe Status new => resolved
2011-10-21 13:27 Jonas Maebe Resolution open => unable to reproduce
2011-10-21 13:27 Jonas Maebe Assigned To => Jonas Maebe
2011-10-21 13:27 Jonas Maebe Note Added: 0053234
2011-10-21 14:27 Jonas Maebe Note Added: 0053238
2011-10-21 17:51 Jonas Maebe FPCOldBugId => 0
2011-10-21 17:51 Jonas Maebe Category Debugger => RTL
2011-10-21 17:51 Jonas Maebe Product Version 0.9.31 (SVN) =>
2011-10-21 17:51 Jonas Maebe Description Updated
2011-10-21 17:51 Jonas Maebe Additional Information Updated