• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: release & memory problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: release & memory problem


  • Subject: Re: release & memory problem
  • From: publiclook <email@hidden>
  • Date: Fri, 2 May 2003 18:08:47 -0400

NSPlaceHolderMutableDictionary is a place holder object returned by [NSMutableDictionarry alloc]. It exists so that a subsequent call to one of its init methods can return an appropriate subclass of NSMutableDictionary. Its purpose is to decide which concrete subclass of NSMutableDictionary you really want.

There is at most one instance on NSMutableDictionary per thread per memory zone. They should not be deallocated. It is harmless to release or autorelease them because they probably implement release and autorelease as a no-op.

My guess is that you have a pointer overrun or under run as follows:
1) You autorelease a valid object that gets put in a release pool.
2) You release the same object causing it to be immediately deallocated. The pointer in the autorelease pool now points to invalid memory.
3) For some reason a new NSPlaceHolderMutableDictionary instance is created (possibly the first or because another memory zone or thread came into existence) and it happens to reuse the memory freed when the other object was deallocated.

Later...

As the autorelease pool is deallocated it releases every object it contains. It holds a pointer to the memory that used to contain some other dealloacted object and now holds a NSPlaceHolderMutableDictionary instance. Hence the error.

You are doing something really wacky in your code. Don't do that.


On Friday, May 2, 2003, at 12:12 AM, Lloyd Dupont wrote:

I have some memory problem :-0 (maybe age ?)

I have a small tool which exit on a SIGSEGV signal when I release the
memory pool.
apparently while trying to delete an (unknown to me)
"NSPlaceholderMutableDictionary" instance.
so I try to figure out when this class is allocated and deallocated by
posing this above class

@implementation DebugObject

- (oneway void) dealloc
{
NS_DURING
const char * cname = isa->name;
if(! strcmp(cname, "NSPlaceholderMutableDictionary")) {
printf("[%s dealloc]\n", cname);
}
NS_HANDLER
NS_ENDHANDLER
[super dealloc];
}
+ alloc
{
NS_DURING
const char * cname = ((Class) self)->name;
if(! strcmp(cname, "NSPlaceholderMutableDictionary")) {
printf("[%s alloc]\n", cname);
}
NS_HANDLER
NS_ENDHANDLER
return [super alloc];
}

@end

as NSObject
int main (int argc, const char * argv[]) {
#if DEBUG
[DebugObject poseAsClass: [NSObject class]];
#endif


the problem is....
it seems this object is never allocated !
and it SIGSEGV at deallocation with a very short call stack (on
NSAutoreleasePool() above it)

I have carefully look at all my retain/release/autorelease (not too
hard it's small tool), they looks good, so far ...
any other tip/ideas for debugging ?
_______________________________________________
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.
_______________________________________________
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.

References: 
 >release & memory problem (From: Lloyd Dupont <email@hidden>)

  • Prev by Date: Calling ObjC instance method from C
  • Next by Date: Re: release & memory problem
  • Previous by thread: release & memory problem
  • Next by thread: Re: release & memory problem
  • Index(es):
    • Date
    • Thread