Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/FireMonkey/Runtime    [ Add a report in this area ]  
Report #:  100788   Status: Closed
[MacOS] Memory leaks in Macapi.ObjectiveC.pas
Project:  Delphi Build #:  16.0.4316.44803
Version:    16.2 Submitted By:   Chris Rolliston
Report Type:  Basic functionality failure Date Reported:  11/6/2011 9:20:24 AM
Severity:    Serious / Highly visible problem Last Updated: 12/19/2012 7:09:15 PM
Platform:    All Mac platforms Internal Tracking #:   288650
Resolution: Fixed (Resolution Comments) Resolved in Build: : Update 4
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 10
Description
In 5 places in Macapi.ObjectiveC.pas, a local TList or TDictionary object is created that is never freed. This causes memory leaks, as shown by the Leaks module of Apple's Instruments application.
Steps to Reproduce:
Create any object through the Delphi to Objective-C bridge, and leaks will result. More discussion here: http://delphihaven.wordpress.com/2011/11/06/memory-leaks-on-os-x/
Workarounds
Copy Macapi.ObjectiveC.pas to your project's directory, and edit it to add the needed calls to <SomeObj>.Free immediately after the calls to <SomeObj>.ToArray.
Attachment
None
Comments

Sebastian Zierer at 12/16/2011 12:52:47 AM -
Search for ToArray and you will find the TList or TDictionary objects that need to be freed in:

function BuildSuperImportMarshalingInfo(Method: TRttiMethod;
                                        Selector: SEL;
                                        out OpArray: TArray<TMarshalOp>): Integer;

function BuildImportMarshalingInfo(Method: TRttiMethod;
                                   Selector: SEL;
                                   out OpArray: TArray<TMarshalOp>): Integer;

function BuildLocalMarshalingInfo(Method: TRttiMethod;
                                  out OpArray: TArray<TMarshalOp>): Integer;

function BuildInvokeData(P: PTypeInfo; IsSuperReference: Boolean):
  TArray<OCMethodInvokeData>;

class function TRegisteredDelphiClass.RegisterClass(P: PTypeInfo;
                                                    Implementing: PTypeInfo)

Tomohiro Takahashi at 6/17/2013 5:01:00 PM -
This issue is same as QC#100788.

Server Response from: ETNACODE01