Closed Bug 166764 Opened 22 years ago Closed 22 years ago

Lots of memory leaks

Categories

(Camino Graveyard :: General, defect)

PowerPC
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: sfraser_bugs, Assigned: sfraser_bugs)

References

Details

(Keywords: memory-leak)

Attachments

(1 file)

Using 'heap' to look at the heap for the application, and checking the heap
after just opening and closing windows, I see tons of memory leaks.

Methodology:
1. Run Navigator, get process ID (enter for <pid> in commands below)
2. Close Navigator windows
3. In termainal, do
     heap <pid> | tail -n +46 | sort > oldheap.txt
(throws away first 46 lines of heap output, leaving the output about cocoa objects)
4. Open a new window, then close it.
5. Do 
     heap <pid> | tail -n +46 | sort > newheap.txt
6. Now compare the two heap logs with:
     diff oldheap.txt newheap.txt > leaksfile.txt

Look at leaksfiel.txt to see what leaked.
You can also run 'leaks <pid>'. To get some useful output from leaks:

leaks <pid> | grep Leak: | awk '{print $3 $4 $5 $6}' | sort | uniq -c | sort -rn
> sortedleaks.txt
Status: NEW → ASSIGNED
DraggableImageAndTextCell leak fix:

Index: src/bookmarks/BookmarksButton.mm
===================================================================
RCS file: /cvsroot/mozilla/chimera/src/bookmarks/BookmarksButton.mm,v
retrieving revision 1.17.2.4
diff -u -r1.17.2.4 BookmarksButton.mm
--- src/bookmarks/BookmarksButton.mm    28 Aug 2002 23:35:04 -0000      1.17.2.4
+++ src/bookmarks/BookmarksButton.mm    6 Sep 2002 02:11:57 -0000
@@ -45,7 +45,7 @@
 {
   if ( (self = [super initWithFrame:frame]) )
   {
-    DraggableImageAndTextCell* newCell = [[DraggableImageAndTextCell alloc] init];
+    DraggableImageAndTextCell* newCell = [[[DraggableImageAndTextCell alloc]
init] autorelease];
     [newCell setDraggable:YES];
     [self setCell:newCell];
 
Fix for a bunch of other leaks:

Index: BrowserWindowController.mm
===================================================================
RCS file: /cvsroot/mozilla/chimera/src/browser/BrowserWindowController.mm,v
...
 -(void)setupSidebarTabs
 {
-    IconTabViewItem   *bookItem = [[IconTabViewItem alloc]
initWithIdentifier:@"bookmarkSidebarCHIconTabViewItem"
-                                  withTabIcon:[NSImage imageNamed:@"bookicon"]];
-    IconTabViewItem   *histItem = [[IconTabViewItem alloc]
initWithIdentifier:@"historySidebarCHIconTabViewItem"
-                                  withTabIcon:[NSImage imageNamed:@"historyicon"]];
+    IconTabViewItem   *bookItem = [[[IconTabViewItem alloc]
initWithIdentifier:@"bookmarkSidebarCHIconTabViewItem"
+                                  withTabIcon:[NSImage imageNamed:@"bookicon"]]
autorelease];
+    IconTabViewItem   *histItem = [[[IconTabViewItem alloc]
initWithIdentifier:@"historySidebarCHIconTabViewItem"
+                                  withTabIcon:[NSImage
imageNamed:@"historyicon"]] autorelease];
 #if USE_SEARCH_ITEM
-    IconTabViewItem *searchItem = [[IconTabViewItem alloc]
initWithIdentifier:@"searchSidebarCHIconTabViewItem"
-                                  withTabIcon:[NSImage imageNamed:@"searchicon"]];
+    IconTabViewItem *searchItem = [[[IconTabViewItem alloc]
initWithIdentifier:@"searchSidebarCHIconTabViewItem"
+                                  withTabIcon:[NSImage
imageNamed:@"searchicon"]] autorelease];
 #endif
 #if USE_PANELS_ITEM
-    IconTabViewItem *panelsItem = [[IconTabViewItem alloc]
initWithIdentifier:@"myPanelsCHIconTabViewItem"
-                                  withTabIcon:[NSImage imageNamed:@"panel_icon"]];
+    IconTabViewItem *panelsItem = [[[IconTabViewItem alloc]
initWithIdentifier:@"myPanelsCHIconTabViewItem"
+                                  withTabIcon:[NSImage
imageNamed:@"panel_icon"]] autorelease];
 #endif
     
     [bookItem   setView:[[mSidebarSourceTabView tabViewItemAtIndex:0] view]];
Index: BrowserTabViewItem.mm
...
 - (void)setLabel:(NSString *)label
 {
-  NSAttributedString* labelString = [[NSAttributedString alloc]
initWithString:label attributes:mLabelAttributes];
+  NSAttributedString* labelString = [[[NSAttributedString alloc]
initWithString:label attributes:mLabelAttributes] autorelease];
   [[mTabContentsView labelCell] setAttributedStringValue:labelString];
 
   [super setLabel:label];
@@ -512,6 +514,17 @@
   [self setTabIcon:newIcon];
   mDraggable = draggable;
   [[mTabContentsView labelCell] setImageAlpha:(draggable ? 1.0 : 0.6)];  
}
Index: IconTabViewItem.mm
===================================================================
RCS file: /cvsroot/mozilla/chimera/src/extensions/IconTabViewItem.mm,v
retrieving revision 1.4
diff -u -r1.4 IconTabViewItem.mm
--- IconTabViewItem.mm  21 Aug 2002 02:06:27 -0000      1.4
+++ IconTabViewItem.mm  6 Sep 2002 06:58:26 -0000
@@ -79,6 +79,7 @@
 {
   [mTabIcon release];
   [mLabelAttributes release];
+  [mLabelString release];
   [mTruncLabelString release];
   [super dealloc];
 }
Index: BrowserWrapper.mm
===================================================================
RCS file: /cvsroot/mozilla/chimera/src/browser/BrowserWrapper.mm,v
retrieving revision 1.30.2.3
diff -u -r1.30.2.3 BrowserWrapper.mm
--- BrowserWrapper.mm	4 Sep 2002 17:50:15 -0000	1.30.2.3
+++ BrowserWrapper.mm	6 Sep 2002 07:17:27 -0000
@@ -131,7 +131,8 @@
   [mDefaultStatusString release];
   [mLoadingStatusString release];
   [mToolTip release];
-
+  [mTitle release];
+  
   [super dealloc];
 }
 
r=brade on all of the above fixes (though you can remove the spaces from the
blank line you added in BrowserWrapper.mm)

I'll dupe some of the bugs I filed since the fixes are here.
Keywords: mlk
*** Bug 164274 has been marked as a duplicate of this bug. ***
There's a leak in GoMenu.mm:

Index: browser/GoMenu.mm
===================================================================
RCS file: /cvsroot/mozilla/chimera/src/browser/GoMenu.mm,v
retrieving revision 1.7
diff -u -r1.7 GoMenu.mm
--- browser/GoMenu.mm	21 Aug 2002 02:06:09 -0000	1.7
+++ browser/GoMenu.mm	1 Nov 2002 05:43:12 -0000
@@ -64,7 +64,7 @@
   if (!wrapper) return nsnull;
   CHBrowserView* view = [wrapper getBrowserView];
   if (!view) return nsnull;
-  nsCOMPtr<nsIWebBrowser> webBrowser = [view getWebBrowser];
+  nsCOMPtr<nsIWebBrowser> webBrowser = getter_AddRefs([view getWebBrowser]);
   if (!webBrowser) return nsnull;
   nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(webBrowser));
   return webNav.get();
These have been fixed.
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: