Discussion:
Memory managment on EOF
Ricardo Strausz
2005-08-25 16:00:59 UTC
Permalink
Hola a ***@s!

I am facing the following problem:
I have to move a database from one machine to other ---to be precise,
from Sybase 11.5 on Win NT, to Sybase 12 on OSX.
Since the versions are not compatible, it is not possible via
standard backup.
After trying some suggestions on the bible (aka PWO), with out
success, I decided to implement an app to do it ---the database is huge!

The basic idea behind the algorithm, is to traverse all entities in
the source-model and, for each one, traverse its data to create new
eos and insert them into the sink-model.

The problem: it is running out of memory!

I already gave the JVM 1024Mb but it looks that it will run out of
memory sooner or later, no mater how many memory I assign to it...

It cross to my mind that there should be a standard way to free the
used memory, say whenever a new entity is going to be traversed.

What is better?
1. re-faulting.
2. using a new editing context for each entity.
3. creating a new store coordinator (for each entity)

How to force to run the garbage-collector after releasing an store
coordinator?
is it necessary?

In five words: how to free system resources?

HELP!

--
Ricardo Strausz
***@mac.com
Business Applied C Objects
http://homepage.mac.com/strausz/baco
+5255 5437 8205
Pierce T. Wetter III
2005-08-25 17:13:18 UTC
Permalink
Post by Ricardo Strausz
I have to move a database from one machine to other ---to be
precise, from Sybase 11.5 on Win NT, to Sybase 12 on OSX.
Since the versions are not compatible, it is not possible via
standard backup.
After trying some suggestions on the bible (aka PWO), with out
success, I decided to implement an app to do it ---the database is huge!
The basic idea behind the algorithm, is to traverse all entities in
the source-model and, for each one, traverse its data to create new
eos and insert them into the sink-model.
The problem: it is running out of memory!
I already gave the JVM 1024Mb but it looks that it will run out of
memory sooner or later, no mater how many memory I assign to it...
It cross to my mind that there should be a standard way to free the
used memory, say whenever a new entity is going to be traversed.
What is better?
1. re-faulting.
2. using a new editing context for each entity.
3. creating a new store coordinator (for each entity)
How to force to run the garbage-collector after releasing an store
coordinator?
is it necessary?
In five words: how to free system resources?
There used to be an EOUtil that could do something like this. Does
that still exists?

Otherwise, it depends on how the ER relationship chart works. In
our case, we have a set of objects that would more or less "own" all
the other objects in the ER tree. So the code would look something
like this:

get master editing context

fetch copies of all the master objects into the master ec (not
that many, so ok)

for each master object:

make a local ec
copy the master object into the local ec (localInstanceOfObject())
do stuff with master object (i.e. copy them into the sink model)
toss local ec

Using the local EC is the key.

If you have a large number of master objects enough that you can't
load all of them into memory at once, then it gets trickier. One way
is to just fetch a list of primary keys using raw rows, then use
objectWithPrimaryKeyValue() to build the objects in the local editing
context.

If your ER tree is more complex (there is no "owner" object, then
YMMV).

Pierce
David Teran
2005-08-25 19:29:15 UTC
Permalink
Hi,
There is some stuff in Wonder's ERXJDBCUtilities that should be
able to copy from one DB to another. I never tried it, but maybe it
gives you some hints. There is no real need to use EOs anyway as
you just want to copy the data.
Hmpf! 'that should be able to copy from one DB to another.' NoNo,
Anjo, that is not fair ;-)

In fact it works perfectly -if- the JDBC driver is not buggy. Here is
a quick documentation:

OK, you need to use ERExtensions and ERJars. Not a big deal, drop me
a line and i'll send a demo app to you.

Then you need this code here, the example takes data from frontbase
and saves it to a postgres database:

NSMutableDictionary sourceDict = new NSMutableDictionary();
sourceDict.setObjectForKey("", "password");
sourceDict.setObjectForKey("_SYSTEM", "username");
sourceDict.setObjectForKey("jdbc:FrontBase://195.135.143.205/
merces/user=_system", "url");
sourceDict.setObjectForKey("com.frontbase.jdbc.FBJDriver",
"driver");
sourceDict.setObjectForKey(Boolean.FALSE, "autoCommit");
sourceDict.setObjectForKey(Boolean.TRUE, "readOnly");

NSMutableDictionary destDict = sourceDict.mutableClone();
destDict.setObjectForKey("jdbc:postgresql://195.135.143.205/
merces", "url");
destDict.setObjectForKey("dev", "password");
destDict.setObjectForKey("dev", "username");
destDict.setObjectForKey("org.postgresql.Driver", "driver");
destDict.setObjectForKey(Boolean.FALSE, "autoCommit");
destDict.setObjectForKey(Boolean.FALSE, "readOnly");

EOModel yourModel = EOModelGroup.defaultGroup().modelNamed
("YourEOModelName");

ERXJDBCUtilities.copyDatabaseDefinedByEOModelAndConnectionDictionaryToDa
tabaseWithConnectionDictionary(yourModel,
sourceDict, destDict);


Thas all!

regards David
Post by Ricardo Strausz
I have to move a database from one machine to other ---to be
precise, from Sybase 11.5 on Win NT, to Sybase 12 on OSX.
Since the versions are not compatible, it is not possible via
standard backup.
After trying some suggestions on the bible (aka PWO), with out
success, I decided to implement an app to do it ---the database is huge!
The basic idea behind the algorithm, is to traverse all entities
in the source-model and, for each one, traverse its data to create
new eos and insert them into the sink-model.
The problem: it is running out of memory!
I already gave the JVM 1024Mb but it looks that it will run out of
memory sooner or later, no mater how many memory I assign to it...
It cross to my mind that there should be a standard way to free
the used memory, say whenever a new entity is going to be traversed.
What is better?
1. re-faulting.
2. using a new editing context for each entity.
3. creating a new store coordinator (for each entity)
How to force to run the garbage-collector after releasing an store
coordinator?
is it necessary?
In five words: how to free system resources?
HELP!
--
Ricardo Strausz
Business Applied C Objects
http://homepage.mac.com/strausz/baco
+5255 5437 8205
_______________________________________________
WebObjects-dev mailing list
http://www.omnigroup.com/mailman/listinfo/webobjects-dev
_______________________________________________
WebObjects-dev mailing list
http://www.omnigroup.com/mailman/listinfo/webobjects-dev
Loading...