Re: Memory management
Re: Memory management
- Subject: Re: Memory management
- From: "Richard Bruch" <email@hidden>
- Date: Tue, 16 Mar 2004 22:54:59 +0100
----- Original Message -----
From: Arturo Pirez <email@hidden>
To: Richard Bruch <email@hidden>
Cc: <email@hidden>
Sent: Tuesday, March 16, 2004 10:38 PM
Subject: Re: Memory management
>
> 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?
>
No. These two lines simply execute the statement and prepare for fetch. So
the memory consumption here is minimal.
> > 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?
>
Yes, this should be exactly the low-level mechanism which EOF itself uses
for obtaining raw data. And this is actually not much different from JDBC
except that thousands of NSDictionary objects(variable "row") are created
and not released. The memory use grows steadily as more and more rows are
fetched. So i hoped that there is some Java trick which allows you to get
rid of all these objects. If there is none, then i should really try it with
plain JDBC.
Can you explain what you mean with an in-memory PrintWriter ? I create it on
a FileOutputStream and assume, it works like any file stream - by using a
limited buffer to collect a reasonable chunk of data and writing it to the
file.
Richard
_______________________________________________
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.