[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Does dropping objects really free memory?
From: |
Fabio Mascelloni |
Subject: |
Re: Does dropping objects really free memory? |
Date: |
Wed, 20 Oct 1999 18:52:05 +0200 |
----- Original Message -----
From: Marcus G. Daniels <address@hidden>
To: <address@hidden>
Sent: Wednesday, October 20, 1999 4:52 AM
Subject: Re: Does dropping objects really free memory?
> >>>>> "FM" == famasce <address@hidden> writes:
>
> FM> I've put the source in
> FM> ftp://ftp.santafe.edu/pub/swarm/users-contrib/incoming/ in the
> FM> hope that someone can help me.
>
I'm slowly resolving my memory problems, but doing this other problems
appear.In particular, what' wrong in this code?
#import <stdio.h>
#import <collections.h>
#import <simtools.h>
#import "Coalition.h"
int main (int argc,const char **argv)
{
int idx;
id member;
id <Array> firstArray;
id <Array> secondArray;
Coalition *coal;
initSwarm (argc,argv);
firstArray=[Array create: globalZone setCount: 30];
secondArray=[Array create: globalZone setCount: 30];
file://fill the first array with objects of class Coalition
for (idx=0;idx<30;idx++)
{
coal=[Coalition createBegin: globalZone];
[coal setLength: 8];
coal=[coal createEnd];
[coal randomInit];
[firstArray atOffset: idx put: coal];
}
file://copy members from first to second
for (idx=0;idx<30;idx++)
{
member=[[firstArray atOffset: idx] copy: globalZone];
[secondArray atOffset: idx put: member];
}
//drop the second array's members
for (idx=0;idx<30;idx++)
[[secondArray atOffset: idx] drop]; <<<= = = = = = = STATUS ACCESS
VIOLATION!
//drop secondArray
[secondArray drop];
return 0;
}
The copy method is so defined:
- copy:(id) aZone
{
Coalition *coal;
unsigned short idx;
coal=[aZone allocIVars:[self class]];
coal->selfFitness=selfFitness;
coal->selfLength=selfLength;
coal->ownerID=ownerID;
coal->selfConfig=(unsigned short*)[aZone alloc:selfLength*sizeof(unsigned
short)];
for (idx=0;idx<selfLength;idx++)
*((coal->selfConfig)+idx)=*(selfConfig+idx);
return coal;
}
I've not understood well when dropping an object gives an S.A.V yet:
a) When you try to drop an object belonging to another collection ?
b) When you try to drop an object that's still referenced by some other?
What else?
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.
Re: Does dropping objects really free memory?, Marcus G. Daniels, 1999/10/19
Re: Does dropping objects really free memory?, famasce, 1999/10/20