bringing objects into the cache

For questions and postings not covered by the other forums
User avatar
ghosttie
Posts: 181
Joined: Sat Aug 15, 2009 1:25 am
Location: Atlanta, GA, USA
Contact:

bringing objects into the cache

Postby ghosttie » Sat Jun 23, 2012 4:45 am

Does calling a method on an object bring it into the cache or only accessing one of its properties?

Specifically I'm looping through a lot of objects and collecting ones that are of a certain type and I don't want to bring any more of them into the cache than I have to. So my question is whether calling Object::isKindOf on each object is going to bring them all into the cache.

The only way I can see of avoiding calling isKindOf on each object is to use getClassForObject, but that doesn't do exactly the same thing as isKindOf...
I have a catapult. Give me all the money or I will fling an enormous rock at your head.

User avatar
ghosttie
Posts: 181
Joined: Sat Aug 15, 2009 1:25 am
Location: Atlanta, GA, USA
Contact:

Re: bringing objects into the cache

Postby ghosttie » Sat Jun 23, 2012 8:05 am

I've answered my own question using Process::getBufferStatistics:

Code: Select all

vars d : Document; jdo : JadeDynamicObject; begin create jdo transient; d := Document.firstInstance; if process.getBufferStatistics(d, jdo) then write "object is in cache"; else write "object is not in cache"; endif; write d.isKindOf(Document); if process.getBufferStatistics(d, jdo) then write "object is in cache"; else write "object is not in cache"; endif; write d.docName; if process.getBufferStatistics(d, jdo) then write "object is in cache"; else write "object is not in cache"; endif; epilog delete jdo; end;
This seems to say that calling isKindOf does not load the object into the cache but reading a property does.
I have a catapult. Give me all the money or I will fling an enormous rock at your head.

murray
Posts: 144
Joined: Fri Aug 14, 2009 6:58 pm
Location: New Plymouth, New Zealand

Re: bringing objects into the cache

Postby murray » Sat Jun 23, 2012 3:26 pm

I think isKindOf() probably just checks the class number from the OID against theClass metadata.
Murray (N.Z.)

Kevin
Posts: 29
Joined: Wed Oct 14, 2009 9:03 am
Location: Christchurch

Re: bringing objects into the cache

Postby Kevin » Fri Jul 06, 2012 9:13 am

murray is correct, isKindOf just checks the class number rather than getting the object. It used to get the object, but was optimized by Jade around version 6 / 6.1.

As it's only reliant on the OID, isKindOf works without exception for both null and invalid object references, which means you can omit a null check when you need to check the type of an object ;)


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 34 guests

cron