Re: java.lang.OutOfMemoryError (Almost SOLVED)
Re: java.lang.OutOfMemoryError (Almost SOLVED)
- Subject: Re: java.lang.OutOfMemoryError (Almost SOLVED)
- From: Ricardo Strausz <email@hidden>
- Date: Thu, 24 Jul 2003 20:55:30 -0500
I tried that; whell at least as the docs said:
http://docs.info.apple.com/
article.html?artnum=75496&sessionID=anonymous|17734041&kbhost=kbase.in
fo.apple.com:80/
but it seem to do nothing in the Cocoa/EO apps; not a problem of OSX,
but of the Java-Bridge (I suppose)... do not know why!
Thanks for the tip on @sum
dino
On jueves, juli 24, 2003, at 16:35 America/Mexico_City, Eric Bergerson
wrote:
I am not sure on Mac, but on a PC, the jvm takes areguments:
-Xms256m -Xmx256m
Which set up the beginning and maximum sizes of the jvm to 256 Meg.
Also, I am not sure if you are aware, but if you have an NSArray of
Eos. To get a sum or other aggregate, you can do something like this:
NSArray array = [self someBigAsArrayOfEos]
NSObject sum = [array valueForKeyPath:"@sum.salary"];
This would return the sum of all of the values associated with salary
in each of the EOs.
- Eric
--On Thursday, July 24, 2003 3:57 PM -0500 Ricardo Strausz
<email@hidden> wrote:
Finally...
After a LOT of try-and-fail, I found something which now is so obvious
(eventhough it was not, at least for me... this only reveals how blind
can someone be): the objects you want to survive after the
AutoRelasePool
is released have to be retained ---eventhough you own them?---. The
final
code look like (it is inside a huge loop):
pool = [NSAutoRealasePool new];
array = [self giveMeAHugeArrayOfEOs];
en = [array objectEnumerator];
int sum = 0;
while(eo = [en nextObject]) sum += [eo intValue];
theSum = [NSNumber numberWithInt:sum];
/*HERE COMES THE IMPORTANT PART:*/
[theSum retain];
[pool release];
[results addObject:theSum]; // at this point, theSum is still a vivid
object ;^()
HOWEVER: I had not found a way to assign more than 64Mb (the default)
to
my JVM in a Cocoa/EO app. If some one find out, please let us know,
Yours,
Dino
Thanks to Chuck and Others who helped solve this.
That probably means you have referenced an object after it has been
release. Be careful that you retain any objects created in the loop
that
need to live after it. And don't refer to pool after releasing it.
Chuck
At 12:28 PM 11/04/2003 -0600, Ricardo Strausz wrote:
I did try some thing as:
pool = [NSAutoreleasePool new];
anArray = [self giveMeAHugeArray];
/* proces the array */
[pool release];
But the app crashes (with bussignal 10)... any idea?
On jueves, abri 10, 2003, at 12:31 America/Mexico_City, Chuck Hill
wrote:
Look at the docs for NSAutoreleasePool. Wrap the inside of your
loops
in an autorelease pool to clean up the temporary objects that you
create. You will need to retain any objects created in the loop
that
need to live after it.
e.g.
for(j=0;j<BLOQUES;j++){
// create pool
// processing here...
// release pool
}
Chuck
Ricardo Strausz wrote:
Szia mindenki!
I just recived the following error:
2003-04-10 10:50:48.720 Clientes[649] java/lang/OutOfMemoryError
Stack Trace:
java.lang.OutOfMemoryError
<<no stack trace available>>
I have to do some statistics in a not-to-log database (5,000
clients
x 50,000 invoices) but I am running out of memory... well, from
Java's point of view, becouse I have 512MB in RAM and 1.3GB in HD,
and, at the end my disk is equal in size.
Is there some way to assign more memory to the JVM??
Does it uses my VM??
I show down my code; is there an ease way to do it more
efficient??
Thanks in advance
Dino
- (IBAction)monto:(id)sender
{
NSArray* nsa = [dgClientes displayedObjects];
NSEnumerator* en = [nsa objectEnumerator];
id eo = nil;
NSArray* facturas = nil;
int i = 0;
int j = 0;
BOOL ok = YES;
int cambiaron = 0;
int MESES = [[forma cellAtIndex:0] intValue];
int BLOQUES = [[forma cellAtIndex:1] intValue];
if([nsa count]>0) eo = [en nextElement];
else return;
while(eo != nil){
facturas = [self ordena:[self facturasDe:eo]
enBloquesDeTamanyo:MESES
desde:[NSCalendarDate dateWithString:@"1 1 1996"
calendarFormat:@"%m
%d %Y"]];
if([facturas count]>BLOQUES){
for(i=0;i<[facturas count]-BLOQUES;i++){
for(j=0;j<BLOQUES;j++){
if([[facturas objectAtIndex:i+j] count]>0) ok = YES;
else {
ok = NO;
break;
}
}
if(ok){
[eo setGrupo:[NSNumber numberWithInt:MESES]];
cambiaron++;
break;
}
}
}
NS_DURING
eo = [en nextElement];
NS_HANDLER
eo = nil;
NS_ENDHANDLER
}
[[forma cellAtIndex:2] setIntValue:cambiaron];
}
- (NSArray*)facturasDe:(id)eo
{
NSString* nss = [NSString stringWithFormat:@"cliente=%@ and
estado>0",[eo folio]];
id eoq = [EOQualifier qualifierWithQualifierFormat:nss:nil];
NSArray* nsa = nil;
[[dgFacturas dataSource] setAuxiliaryQualifier:eoq];
[dgFacturas fetch:self];
nsa = [dgFacturas displayedObjects];
return nsa;
}
- (NSArray*)ordena:(NSArray*)nsa
enBloquesDeTamanyo:(int)meses
desde:(NSCalendarDate*)desde
{
NSMutableArray* nsmaa = [NSMutableArray array];
NSMutableArray* nsmab = [NSMutableArray array];
NSCalendarDate* nscda = desde;
NSCalendarDate* nscdb = [nscda dateByAddingYears:0
months:meses
days:0
hours:0
minutes:0
seconds:0];
NSEnumerator* en = [nsa objectEnumerator];
id eo = nil;
NSCalendarDate* eoFecha = [NSCalendarDate alloc];
if([nsa count]>0) eo = [en nextElement];
else return nsmaa;
while(eo != nil){
[eoFecha initWithString:[[[eo fecha] toString]
substringToIndex:11]
calendarFormat:@"%Y-%m-%d"];
if([[eoFecha laterDate:nscda] isEqual:eoFecha]
&& [[eoFecha laterDate:nscdb] isEqual:nscdb]){
[nsmaa addObject:eo];
NS_DURING
eo = [en nextElement];
NS_HANDLER
eo = nil;
NS_ENDHANDLER
} else {
[nsmab addObject:nsmaa];
nsmaa = [NSMutableArray array];
nscda = nscdb;
nscdb = [nscda dateByAddingYears:0
months:meses
days:0
hours:0
minutes:0
seconds:0];
}
}
[eoFecha release];
return nsmab;
}
--
Chuck Hill email@hidden
Global Village Consulting Inc.
http://www.global-village.net
_______________________________________________
EOF mailing list
email@hidden
http://www.omnigroup.com/mailman/listinfo/eof
--
Chuck Hill email@hidden
Global Village Consulting Inc.
http://www.global-village.net
Dino
http://homepage.mac.com/strausz
_______________________________________________
EOF mailing list
email@hidden
http://www.omnigroup.com/mailman/listinfo/eof
Sincerely,
Eric Bergerson
Objective Technologies, Inc.
Phone: 718 997 9741
"Character is what you are in the dark"
- Dr. Emilio Lazardo
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.