Most commercial, shareware apps leak memory?
Most commercial, shareware apps leak memory?
- Subject: Most commercial, shareware apps leak memory?
- From: Jerry Krinock <email@hidden>
- Date: Sat, 20 Mar 2004 13:49:59 -0800
During the past few weeks I have been testing my app with the command-line
tool "leaks", trying to fix all the leaks which I created when I was first
learning Cocoa.
Thanks to the good advice I've received from y'all, I've have eliminated
most of the big leaks, but in a typical run my app still makes maybe "15
leaks for 2000 total leaked bytes". However, anyplace where I try to add
additional -release or -autorelease messages causes a crash.
This may be with OK my app, since it should never be run more than a few
minutes before quitting. My wife says I am too much of a perfectionist, but
it bothers me.
To see how I'm doing, I used my Powerbook, OS 10.3.3, for a couple days,
leaving many applications open, and wrote and then ran a Perl script to spit
out a summary of all the "leaks" in all running "/Applications/". The
result, as you can see below, is that my 15 leaks and 2000 bytes ain't too
bad, compared with the big boys', even Apple's apps!
So, I want to know, should I:
(a) tell my mother that I'm a Cocoa programmer now
(b) work harder to fix the remaining leaks
(c) go to Iraq and look for Weapons of Mass Destruction
By the way, MallocDebug either crashes or "cannot read" any app it launches,
but let's leave that for another topic.
Jerry
LaunchBar: 23 leaks for 1392 total leaked bytes.
CopyPaste-X: 313 leaks for 24368 total leaked bytes.
AutoSync: 0 leaks for 0 total leaked bytes.
MemoryStick: 435 leaks for 30000 total leaked bytes.
Key Caps: 38 leaks for 4432 total leaked bytes.
LocationXHelper: 1 leak for 0 total leaked bytes.
Path Finder: 29784 leaks for 1778512 total leaked bytes.
QuicKeys: 986 leaks for 35088 total leaked bytes.
CopyPasteMB: 1 leak for 0 total leaked bytes.
QuicKeysBackgroundEngine: 1 leak for 0 total leaked bytes.
QuicKeysHotKeyHelper: 38 leaks for 1216 total leaked bytes.
Console: 4 leaks for 128 total leaked bytes.
StuffIt Deluxe: 168 leaks for 8336 total leaked bytes.
SyncXReg: 0 leaks for 0 total leaked bytes.
TextEdit: 10 leaks for 528 total leaked bytes.
Safari: 801 leaks for 34448 total leaked bytes.
MI-SUGAR: 273 leaks for 12032 total leaked bytes.
MallocDebug: 228 leaks for 9312 total leaked bytes.
Terminal: 71 leaks for 2912 total leaked bytes.
Grab: 1544 leaks for 140176 total leaked bytes.
GraphicConverter.app: 1548 leaks for 112688 total leaked bytes.
Preview: 13 leaks for 496 total leaked bytes.
RPN Calculator: 4 leaks for 240 total leaked bytes.
Adobe Reader: 67 leaks for 2256 total leaked bytes.
CodeWarrior IDE: 233 leaks for 13888 total leaked bytes.
Interface Builder: 23 leaks for 944 total leaked bytes.
Xcode: 1794 leaks for 78432 total leaked bytes.
Igor Pro Carbon: 890 leaks for 42176 total leaked bytes.
AppleWorks 6: 106 leaks for 5840 total leaked bytes.
Property List Editor: 52 leaks for 1872 total leaked bytes.
Quicken 2004: 610 leaks for 29264 total leaked bytes.
Mathematica: 204 leaks for 16336 total leaked bytes.
ProcessViewer: 39 leaks for 5904 total leaked bytes.
ConceptDrawPro: 2607 leaks for 97328 total leaked bytes.
Microsoft Entourage: 2750 leaks for 71088 total leaked bytes.
Microsoft Database Daemon: 337 leaks for 6400 total leaked bytes.
Microsoft Word: 630 leaks for 25456 total leaked bytes.
Microsoft Excel: 332 leaks for 6656 total leaked bytes.
BBEdit 6.5: 205 leaks for 12880 total leaked bytes.
#!/usr/bin/perl
# This is my first Perl script.
#
# Yeah, yeah I know there are people smarter than me
# out there who could probably have written this in
# one line of awk.
&GetProcessInfo() ;
for ($j=0; $j<$i; $j++)
{
$_ = $appName{$pid[$j]} ;
if (/\/Applications\//)
{
#/.*\/([\s\S]+)\.app/ ;
/\/([^\/]+) -psn[\d_]+/ ;
$shortName = $1 ;
&GetTheLeak() ;
printf "%s: %s\n", $shortName, $theLeak ;
}
}
# end of main
sub GetProcessInfo
{
open(psPipe,"ps -ax|");
$i=0;
while (<psPipe>)
{
chomp;
@psField = split(' ', $_, 5);
$pid[$i] = $psField[0];
$appName{$pid[$i]} = $psField[4];
$i++;
}
close(psPipe);
printf("Found %i processes.\n", $i) ;
}
sub GetTheLeak()
{
$cmd = "leaks " . $pid[$j] . " | grep total |" ;
#printf("The command is \"%s\"\n", $cmd) ;
open F, $cmd or die "fork: $!";
while (<F>)
{
chomp;
$theLeak = $_ ;
/\d+ \S+ for \d+ total leaked bytes./ ;
$theLeak = $& ;
}
close F ;
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.