Page 1 of 1

bringing objects into the cache

Posted: Sat Jun 23, 2012 4:45 am
by ghosttie
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...

Re: bringing objects into the cache

Posted: Sat Jun 23, 2012 8:05 am
by ghosttie
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.

Re: bringing objects into the cache

Posted: Sat Jun 23, 2012 3:26 pm
by murray
I think isKindOf() probably just checks the class number from the OID against theClass metadata.

Re: bringing objects into the cache

Posted: Fri Jul 06, 2012 9:13 am
by Kevin
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 ;)