Re: Memory management
Re: Memory management
- Subject: Re: Memory management
- From: Arturo Pérez <email@hidden>
- Date: Tue, 16 Mar 2004 16:38:58 -0500
On Mar 16, 2004, at 1:39 PM, Richard Bruch wrote:
Hi Arturo
here is my code so you can see what goes on. The question is whether
there
is a means to get this code working for large queries.
I'm surprised none of the EOF heavy hitters have chimed in. I'll give
it a shot,
although I'm more of a modeler than a troubleshooter with regards to
these issues.
try
{
PrintWriter pw = new PrintWriter(new FileOutputStream(tableName +
".dat"));
EODatabaseChannel dc = dctx.availableChannel();
ac = dc.adaptorChannel();
if(!ac.isOpen())
ac.openChannel();
ac.evaluateExpression(EOSQLExpression.expressionForString(stmt));
ac.setAttributesToFetch(ac.describeResults());
I would assume that one of the immediately two preceding lines are
sucking
up all the memory. Can you confirm that?
NSDictionary row = null;
while((row = ac.fetchRow()) != null)
{
for(i = 0; i < fieldCount; i ++)
{
Object res = row.objectForKey(keys.objectAtIndex(i));
if(i > 0)
pw.print('\t');
if(res != null && res != nullVal)
pw.print(res);
}
pw.println();
}
pw.close();
}
Nothing above should be causing problems. Unless your PrintWriter is
an in-memory PrintWriter?
The fetchRow might be doing things. But by working at this level
aren't you bypassing most of the EOF magic? On the other hand, the
code above isn't really all that different than what you'd do with
straight JDBC. Have you tried that for comparison purposes?
catch(Exception e)
{
System.out.println("Error occured: " + e);
try
{
if(ac != null)
ac.cancelFetch();
}
catch(Exception xe)
{
}
}
Thank you
Richard
----- Original Message -----
From: Arturo Pirez <email@hidden>
To: Richard Bruch <email@hidden>
Cc: <email@hidden>
Sent: Tuesday, March 16, 2004 7:26 PM
Subject: Re: Memory management
On Mar 16, 2004, at 1:09 PM, Richard Bruch wrote:
Hi all,
a Java question to the smartest Java community in the world.
WO allows to quickly build HTML interface to a database so it seems
reasonable
to use it to execute flexible data exports(XML or plain text for
example).
However with Java(unlike C) it is not quite trivial if the
tables(queries) are
large. I tried to export a subset of a large table using raw sql
EOAdaptorChannel methods. Even in that rather inexpensive case the
memory
consumption after just 300 000 rows reaches 1 GB which is hardly
acceptable.
Is there a means to deallocate memory(in this case the dictionaries
returned
by EOAdaptorChannel.fetchRow()) in some predictable way or to force
the
virtual machine to reclaim garbage ?
Or should i rather forget doing such things in Java ?
We used to do that sort of thing all the time with Java/JDBC. So it's
probably not a java issue.
Can you be more specific as to what you're doing? Are you asking
what's the best way to clear out the EOF snapshots etc?
----
WO in philadelphia - wanna cheesesteak with that?
Please visit webobjects.meetup.com.
----
WO in philadelphia - wanna cheesesteak with that?
Please visit webobjects.meetup.com.
_______________________________________________
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.