Re: Memory allocation overhead

Eric Bezault <[email protected]>
Newsgroups gmane.comp.lang.eiffel.gobo.devel
Message-ID <[email protected]>
Colin Paul Adams wrote:
>>>>>> "Eric" == Eric Bezault <[email protected]> writes:
> 
>     Eric> technique that I use is to try to reuse objects, rather than
>     Eric> giving them back to the GC and creating new ones right
>     Eric> after. In gec, I have AST visitor classes to implement the
>     Eric> different Eiffel "Degree" compilation passes. They all try
>     Eric> to keep the intermediary objects that they need to process a
>     Eric> given imput class. They reuse these intermediary objects
>     Eric> when processing the next input class, and so forth.
> 
> Can you point me to a specific example?

Instead of having iterator objects, I use the visitor pattern.
See the descendants of ET_AST_PROCESSOR. And for a given task
I use the same visitor object on all classes, instead of having
a different object each time. This object can then keep some
context that will be reinitialized each time (without necessarily
having to create new objects). For example in
ET_FEATURE_ADAPTATION_RESOLVER, this visitor uses hash-tables
in order to make sense out of the inheritance clause feature
adaptation of the class being processed. This visitor object
is reused for all input classes, without having to create a new
set of hash-tables each time.

> I am currently trying this with the iterators used to evaluate XPath
> sequences. I am retaining copies on a once DS_ARRAYED_STACK. So far,
> this is actually increasing the runtime (but it appears sensitive to
> the size of the stack, so I am currently trying with just a DS_CELL to
> see if this is better).

I didn't mean to implement yourself a memory management system
by hand. It's not obvious that the time spent doing this manual
memory management, with a pool of objects, will be more efficient
than the GC itself.

-- 
Eric Bezault
mailto:[email protected]
http://www.gobosoft.com

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.