Thread: [Modeling-users] unloading CustomObjects
Status: Abandoned
Brought to you by:
sbigaret
From: Yannick G. <yan...@sa...> - 2003-07-22 18:29:37
|
=2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi ! Once the object is loaded in an EditingContext, is there a way to unload it= ? I don't want to kick it from the DB, just free some RAM... There is forgetObject() but the doc told not to use it. Thanks in advance ! =2D --=20 Yannick Gingras Byte Gardener, Savoir-faire Linux inc. (514) 276-5468 =2D----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/HYKOrhy5Fqn/MRARAiR0AKCQ+Fi4Ico43tGfGzbjDg9gzJqvKQCgjzdA qHy8gi7QPvvTAIb2g5AZ69U=3D =3DW7vE =2D----END PGP SIGNATURE----- |
From: Sebastien B. <sbi...@us...> - 2003-07-22 19:11:31
|
Yannick Gingras <yan...@sa...> wrote: > Hi ! >=20 > Once the object is loaded in an EditingContext, is there a way to unload = it ? >=20 > I don't want to kick it from the DB, just free some RAM... There is > forgetObject() but the doc told not to use it. First: you're completely right, forgetObject() is for internal use only. You need EditingConext.refaultObject(). Don't search your local copy, it does not have it; I was sure this was implemented, and it is... but not where I first expected to find it. Check the ml archives:; (this was in march) https://sourceforge.net/mailarchive/forum.php?thread_id=3D1884326&forum_id= =3D10674 I've quickly checked the implementation & at the test I proposed there, so here is my suggestion: you can use it as-is, given that: - you're not applying it on deleted, inserted or modified objects, (BTW: it will become an error to refault a deleted or an inserted object) - you stick to EC.refaultObject and do not try to call DBContext.refaultObject - you do not use it with a nested ec. (I'm not saying this won't work, it probably will... but it needs to be tested before I can say this is supported). This request comes up on a regular basis, I guess I should consider integrating it in the core. Any other vote for this, anyone? -- S=E9bastien. |
From: Mario R. <ma...@ru...> - 2003-07-23 06:55:40
|
Sebastien Bigaret wrote: > Yannick Gingras <yan...@sa...> wrote: >> Hi ! >> >> Once the object is loaded in an EditingContext, is there a way to >> unload it ? >> >> I don't want to kick it from the DB, just free some RAM... There is >> forgetObject() but the doc told not to use it. > > > First: you're completely right, forgetObject() is for internal use > only. > > You need EditingConext.refaultObject(). Don't search your local copy, > it > does not have it; I was sure this was implemented, and it is... but not > where I first expected to find it. > > Check the ml archives:; (this was in march) > https://sourceforge.net/mailarchive/ > forum.php?thread_id=1884326&forum_id=10674 > > I've quickly checked the implementation & at the test I proposed > there, so here is my suggestion: you can use it as-is, given that: > > - you're not applying it on deleted, inserted or modified objects, > (BTW: it will become an error to refault a deleted or an inserted > object) > > - you stick to EC.refaultObject and do not try to call > DBContext.refaultObject > > - you do not use it with a nested ec. > > (I'm not saying this won't work, it probably will... but it needs to > be tested before I can say this is supported). > > This request comes up on a regular basis, I guess I should consider > integrating it in the core. Any other vote for this, anyone? I can see this being very useful, My question is how do you keep track of which objects need to be freed? Do you do the bookkeeping separately? It might be nice to have EC's that automate this according to some criteria, such as, automatically drop (unfetch?) objects not accessed since 1 hour, or automatically unfetch all the least recently accessed objects beyond N, where N is some positive number (i.e. keep only the most recently accessed N objects). mario |
From: Sebastien B. <sbi...@us...> - 2003-07-23 11:20:36
|
Mario Ruggier <ma...@ru...> wrote: [About EditingContext.refaultObject()] > I can see this being very useful, My question is how do you > keep track of which objects need to be freed? Do you do the > bookkeeping separately? It might be nice to have EC's that > automate this according to some criteria, such as, automatically > drop (unfetch?) objects not accessed since 1 hour, or automatically > unfetch all the least recently accessed objects beyond N, where N is > some positive number (i.e. keep only the most recently accessed N > objects). This is the second step, right, the automation of the process will be made separately. This API only allows you to make it by hand. However, rethinking of this, I'm wondering if the way it is done will actually free as much memory as expected... Here are details on the process exposed in the patch: - deincrement the snapshot reference count for an object in the database's cache. If the refaulted object is the last one referencing the snapshot, the snapshot is freed. - revert the object into a fault. Doing this basically means: call __init__() to reset its value to their defaults, and mark it as a fault by storing an instance of AccessFaultHandler in it. This step does not free a lot of memory, although your objects' attributes have a big memory footprint: basically, you still have the reinitialized object in the EC. So the most significant impact on memory (unless, I repeat, your objects are quite big and some of their attributes contains instances, such as FixedPoint instances) will occur when forgetting the snapshots.=20 Hmmm... This needs to be checked in details. I'll probably also compare with ZODB ghosting mechanisms and its impact on memory. Probably other approaches might be taken, such as: - having a shared EditingContext holding mostly read-only objects that are used by an application: this would make it possible to manipulate these objects in <n> different ECs while having only one (instead of <n>) instance for each on them, - changing the object's class into FaultHandler, instead of reinitializing its values and storing a FaultHandler instance in it. To be continued... -- S=E9bastien. |