NSTask memory leak
NSTask memory leak
- Subject: NSTask memory leak
- From: Stefan Werner <email@hidden>
- Date: Wed, 29 Nov 2006 17:50:19 +0100
Hi,
I'm facing a situation where my NSTask doesn't seem to release its
memory, even though I'm properly releasing it and the AutoreleasePool
around it. I am using it from a Carbon app, does that maybe make a
difference?
Appended is how I wrapped NSTask in a C++ class (it's an abstraction
class for platform independence). When I run my code using this class
in ObjectAlloc, it tells me that NSTask and its copy of the arguments
array are leaking.
I would guess that I'm doing something wrong with the AutoreleasePool?
Thanks,
Stefan
class BProcessCocoa : public BProcess
{
public:
BProcessCocoa(const BPoserPath& iExecutable, const int argc, const
char* argv[]);
virtual ~BProcessCocoa();
virtual bool IsRunning() const;
virtual int ReturnCode() const;
virtual void Terminate();
virtual int WaitUntilFinished();
private:
NSTask* mTask;
NSAutoreleasePool* mPool;
};
BProcessCocoa::BProcessCocoa(const BPath& iExecutable, const int
argc, const char* argv[])
{
NSApplicationLoad();
mPool = [[NSAutoreleasePool alloc] init];
mTask = [[NSTask alloc] init];
[mTask setLaunchPath:[NSString
stringWithUTF8String:iExecutable.GetFullPath()]];
NSMutableArray* array = [NSMutableArray arrayWithCapacity:argc];
for (int i = 0; i < argc; i++)
{
[array addObject:[NSString stringWithUTF8String:*argv]];
argv++;
}
[mTask setArguments:array];
[mTask launch];
}
BProcessCocoa::~BProcessCocoa()
{
[mTask waitUntilExit];
[mTask release];
[mPool release];
}
int BProcessCocoa::ReturnCode() const
{
int val = [mTask terminationStatus];
return val;
}
int BProcessCocoa::WaitUntilFinished()
{
[mTask waitUntilExit];
return ReturnCode();
}
bool BProcessCocoa::IsRunning() const
{
bool b = [mTask isRunning];
return b;
}
void BProcessCocoa::Terminate()
{
[mTask terminate];
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden