Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Debugger/Evaluator ToolTips    [ Add a report in this area ]  
Report #:  73762   Status: Open
Memory leak in target app if using Debugger's evaluator tooltips
Project:  Delphi Build #:  2009, ... XE3
Version:    17.1 Submitted By:   Alex Alexeev
Report Type:  Basic functionality failure Date Reported:  5/9/2009 3:48:01 AM
Severity:    Commonly encountered problem Last Updated: 1/13/2013 6:14:54 PM
Platform:    All platforms Internal Tracking #:   269362
Resolution: None (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 18
Description
First see steps to reproduce.

I've also added a FastMM4 in FullDebugMode and it showed the following call stack:

This block was allocated by thread 0x1C68, and the stack trace (return addresses) at the time was:
405843 [System.pas][System][System.@NewUnicodeString][18113]
4052CC [System.pas][System][System.@UStrAsg][16885]
40F24F [Project8.dpr][Project8][Project8.TClss.GetString][17]
20036
77674911 [BaseThreadInitThunk]
77C8E4B6 [Unknown function at RtlInitializeExceptionChain]
77C8E489 [Unknown function at RtlInitializeExceptionChain]

The 0x1C68 is a main thread here.
Steps to Reproduce:
Create a new console application and use this code:

program Project8;
{$APPTYPE CONSOLE}
uses
  SysUtils;

type
  TClss = class
   strict private
      function GetString: string;
   public
      property Str: string read GetString;
   end;

function TClss.GetString: string;
begin
  Result := 'string'
end;

var
  Obj: TClss;
begin
  try
    ReportMemoryLeaksOnShutdown := True;
    Obj := TClss.Create;
    try
     writeln(Obj.Str);
    finally
     Obj.Free
    end;
  except
    on E:Exception do
      Writeln(E.Classname, ': ', E.Message);
  end;
end.

1. Run this application under debugger. It will run correctly.
2. Set a breakpoint on line "writeln(Obj.Str);" and run application again.
3. After stop, hover Obj.Str with mouse to see its value. Hit F9 to run application.
4. There will be a message about leaked UnicodeString.
Workarounds
Don't use memory leak detection while debugging.
Attachment
None
Comments

Sergiy Kheylyk at 1/11/2013 12:00:23 AM -
Still exists in XE Version 15.0.3953.35171

Tomohiro Takahashi at 1/13/2013 6:17:21 PM -
Thanks for the notification.
Unfortunately, this issue still exists in Delphi XE3 Update 1...

and this is a comment from internal tracking system.
<<<<<<<<
This only happens when evaluating without side effects (function calls) enabled.

If you add a watch on "Obj.Str" and make sure that "Allow side effects..." is enabled for that watch, then the leak does not occur.  If you do not allow side effects for the watch (which is the default and is how the eval tooltips work), then the leak is reported.
>>>>>>>>

Server Response from: ETNACODE01