Reuse of objects versus create and delete in order to keep m

Discussions about design and architecture principles, including native JADE systems and JADE interoperating with other technologies
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Reuse of objects versus create and delete in order to keep m

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:28 am

by cnwep1 >> Thu, 21 Nov 2002 3:44:31 GMT

Hello,

Imagine your system creates some thousands of short lived persistent objects regularly e.g. you create 50,000 of these objects daily and then on a weekly basis you have a process that goes through and deletes them.

Your system is 24x7x52 and down time for housekeeping is to be kept to a minimum. You run the database with the SpaceReuseOption turned off because you want maximum performance at the expense of disk space. However you don't want disk space to grew too rapidly nor do you necessarily want to do lots of map file compaction.

So has anybody built something so that instead of deleting these short lived objects it just marks them as deleted and will then recyle them when a new object is required (some kind of 'Factory' thing that knows how to create new objects or recycle old ones). Has anybody done this with persistent objects? Any benefits or performance improvements?

Hope this makes sense.

Eric in Dunedin (city of soggyness)

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Reuse of objects versus create and delete in order to keep m

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:28 am

by allistar >> Thu, 21 Nov 2002 4:02:12 GMT

Interesting concept. I have never built (nor needed) something like
this but I wouldn't imagine it would be overly complicated, maybe something like this:

- have a property called "amDeleted"
- when you want a persistent instance of the object, you should
actually create a transient instance and pass it to a "manager"
object. That would return you a persistent object with all of the properties the same. The manager can be clever enough about whether to create a new object or whether to "recycle" an existing one.

I would image there would be peformance benefits as you don't need to make a trip top the server when you create the persistent object (although you would when you commit the transaction).

My 2c worth,
Allistar.

------------------------------------------------------------------
Allistar Melville
Software Developer
Auckland, NEW ZEALAND

Greentree International,
Developer of Greentree Financial Software. ------------------------------------------------------------------

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Reuse of objects versus create and delete in order to keep m

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:28 am

by cnwdad1 >> Thu, 21 Nov 2002 4:12:24 GMT

I've done something similar to this before.

Presumably the object has an owner ? If so, you could have two instances of the owner class, one for "live" objects, the other for "dead" objects. When you want to reuse a dead object, just reset the reference to its owner to the live one. When you no longer want to use it, reset the reference to the dead owner.

You still have some overhead when the object is moved between the owners' collections however.

regards,
darrell.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Reuse of objects versus create and delete in order to keep m

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:28 am

by PWCDEMO >> Wed, 29 Jan 2003 1:17:15 GMT

I have also done this before. If you want to check out references on the web you may want to use the phrase 'object pooling'.

Check out the Factory and Singleton design patterns and you'll be off and running in no time. Also you can check out the .Net framework object pooling support for ideas on how to implement this in Jade.

The approach below would work nicely.

- Chris


Return to “Design and Architecture”

Who is online

Users browsing this forum: No registered users and 3 guests

cron