Opened 4 months ago

Closed 3 months ago

Last modified 3 months ago

#16223 closed defect (fixed)

wxDataViewColumn wxDVCNSTableColumn memory leak wxOSX-Cocoa

Reported by: johnr Owned by: VZ
Priority: normal Milestone:
Component: wxOSX-Cocoa Version: dev-latest
Keywords: wxDataViewColumn wxDVCNSTableColumn memory leak Cc:
Blocked By: Blocking:
Patch: yes

Description

wxDataViewColumn fails to release wxDVCNSTableColumn in its dtor.
See ticket #16210 for mem leak report.
The following diff fixes column leaks but there are still a few more related to wxDataViewCustomRenderer

Index: src/osx/cocoa/dataview.mm
===================================================================
--- src/osx/cocoa/dataview.mm	(revision 76432)
+++ src/osx/cocoa/dataview.mm	(working copy)
@@ -3210,6 +3210,7 @@
 
 wxDataViewColumn::~wxDataViewColumn()
 {
+    [m_NativeDataPtr->GetNativeColumnPtr() release];
     delete m_NativeDataPtr;
 }

Change History (4)

comment:1 Changed 4 months ago by johnr

  • Summary changed from wxDataViewColumn wxDVCNSTableColumn and wxDataViewCustomRenderer memory leak wxOSX-Cocoa to wxDataViewColumn wxDVCNSTableColumn memory leak wxOSX-Cocoa

The diff I posted yesterday for wxDVCNSTableColumn memory leaks is not a final cure for that problem. It does fix column leaks for the sample's dvc code but we need to examine it further both for effectiveness with other code and correct placement in the code. It might be better to create a dtor for wxDataViewColumnNativeData and do it in there.

I have modified this ticket and created a separate ticket with patch for the renderer memory leak.

comment:2 Changed 4 months ago by johnr

  • Patch set

After looking at this again, nativecolumn is added to and owned by the outlineview. It makes more sense to release nativecolumn once it is added to the outlineview. This fixes mem leaks in the sample and in my own code.

Index: src/osx/cocoa/dataview.mm
===================================================================
--- src/osx/cocoa/dataview.mm	(revision 76432)
+++ src/osx/cocoa/dataview.mm	(working copy)
@@ -2045,6 +2045,8 @@
     // specified position the column is first appended and - if necessary -
     // moved to its final position:
     [m_OutlineView addTableColumn:nativeColumn];
+    [nativeColumn release];
+    
     if (pos != static_cast<unsigned int>([m_OutlineView numberOfColumns]-1))
         [m_OutlineView moveColumn:[m_OutlineView numberOfColumns]-1 toColumn:pos];
 

comment:3 Changed 3 months ago by VZ

  • Owner set to VZ
  • Resolution set to fixed
  • Status changed from new to closed

In 76636:

Don't leak wxDataViewCtrl column objects in wxOSX/Cocoa.

NSOutlineView addTableColumn method takes ownership of the column passed to
it, so we must release it ourselves to avoid leaking it.

Closes #16223.

comment:4 Changed 3 months ago by VZ

In 76640:

Don't leak wxDataViewCtrl column objects in wxOSX/Cocoa.

NSOutlineView addTableColumn method takes ownership of the column passed to
it, so we must release it ourselves to avoid leaking it.

Closes #16223.

Note: See TracTickets for help on using tickets.