discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re[2]: GS Extensions and retain count problem


From: Manuel Guesdon
Subject: Re[2]: GS Extensions and retain count problem
Date: Sat, 29 Dec 2001 19:16:03 +0100 (CET)

On Fri, 28 Dec 2001 17:42:20 +0000 Richard Frith-Macdonald 
<richard@brainstorm.co.uk> wrote:
 >| On Friday, December 28, 2001, at 04:17 PM, Manuel Guesdon wrote:
 >| 
 >| > Hi,
 >| >
 >| > I had some trouble with GC* objects and found that after +alloc -init, 
 >| > their retain count seems strange.
 >| > I've attached a small program to test this.
 >| >
 >| > doing a +new on  the following objects set a retainCount of 1:
 >| > NSObject
 >| > NSArray
 >| > NSMutableDictionary
 >| > GCObject
 >| >
 >| > But for the following, it set a retain count of 0:
 >| > GCMutableArray
 >| > GCArray
 >| > GCDictionary
 >| >
 >| > I can't see any reason in the code.
 >| > If you run the test app, do you get the same result (with debug=yes) ?
 >| > If yes, is it 'normal' ?
 >| 
 >| As the 'GC' classes are garbage collecting things, I would hardly expect 
 >| their
 >| retain counts to make any sort of obvious sense.  You need to look at 
 >| the GCObject source.

Thnak you Richard. As far as I can see the retain count of just allocated 
garbage collectable objects has sense (at
least it should be coherent between GCObject, GCArray and GCDictionary).

I've found some things:

In GCArray (for exemple), +initialize, there's a call to add behaviour:
        class_add_behavior(self, [GCObject class]);
(GCArray inherit from NSArray)

As far as I understand, this should mean that a call to GCArray +allocWithZone: 
should call GCObject +allocWithZone. Is
it right ?
I've added traces and when I alloc a GCArray, it call 
        NSObject +alloc
and  NSArray +allocWithZone:
but not GCObject +allocWithZone.
So the refCount stay to 0 not 1 as it should be (please correct me if I'm 
wrong).

Do you think this mean that behaviour doesn't work well ? Or may be I'm 
completely wrong on how all this should work :-)

Thanks.

Manuel


--
______________________________________________________________________
Manuel Guesdon - OXYMIUM <mguesdon@oxymium.net>
14 rue Jean-Baptiste Clement  -  93200 Saint-Denis  -  France
Tel: +33 1 4940 0999  -  Fax: +33 1 4940 0998




reply via email to

[Prev in Thread] Current Thread [Next in Thread]