xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas DeWeese <Thomas.DeWe...@Kodak.com>
Subject Re: how to dispose JSVGCanvas?
Date Tue, 15 Feb 2005 16:33:37 GMT
Hi Lukasz,

>> Lukasz Matuszczak wrote:
>>> I am not sure what is a proper way to close JSVGCanvas, and all its 
>>> inner objects and threads. Do I have to use "stopProcessing" method 
>>> or is calling of "dispose" method sufficient?.

> Thomas DeWeese wrote:
>>    Dispose should be enough (it will call stopProcessing if something
>> is going on).

Lukasz Matuszczak wrote:

> Ok, so is calling "dispose" call always enough? or do I have to call any 
> other methods, for example unregister all listeners, flush caches, or 
> something?

    Right now you should probably call 'flush', and it seems you
want to call 'flushImageCache' as well (although I truly don't
think this is needed), I'm considering how to add the equivalent of
'flush' to the dispose method (doing it 100% correct is a bit
tricky since dispose might not actually clean up totally until some
time later when other threads complete).

>>> I want to free all image caches too. Does method flushImageCache() 
>>> from JSVGComponent fulfil my needs or do I need to call flush() from 
>>> JGVTComponent?
>>    'flushImageCache' is different from 'flush' on the JGVTComponent.
>> I should have dispose call flush() (thanks for bringing this to my
>> attention).
>>    The Image cache uses SoftReferences so they will clear as soon as
>> there is memory pressure.
> Yes, I understand it, but i would like to clear the image cache while 
> disposing a JSVGCanvas, because I know i will never use this. 

    AFAIK, there is essentially no difference between no reference
and a soft-reference.  The only advantage (and reason for the API)
is so that you can clean the cache if things change behind it's back
(i.e. the user requests a 'shift-reload').

> Therefore the image cache objects will become available for garbage 
> collecting, even if there is no memory pressure (because they won't be 
> even softly reachable). Am i missing something? I hope that Image Cache 
> is not static and is connected with concrete document.

    The image cache _is_ static with the key being URL's (emphasis on
the 'U' in URL).  As I said all it ever holds is soft references so
under memory pressure everything will clear.  Certainly, this is how
every other browser's cache works.

> Does method "flushImageCache()" clear image cache, even if there is no 
> memory pressure?

    It removes the entries from the cache (the entries will no longer
be even softly reachable) of course nothing is ever GC'd unless
there is memory pressure - so your question becomes a bit
philosophical ;)

>>> I haven't found any detailed description of it,

>>    What sort of description would be useful?  Can you point me to
>> an example of what you would be interested in?
> I think that more detailed description of methods in Javadoc would be 
> useful. For example "dispose" method has no comment at all.

    Hmm, I'll look at trying to comment the swing stuff a little
better, but there are ~1500 classes so I can't fix everything,
targeted areas that people consider the most problematic would
be helpful.

> I would like also to see examples of typical usage of different types of 
> listeners. Sometimes I am little confused which listener and which 
> method of it is a proper place to put my code in, so I think that 
> description in http://xml.apache.org/batik/svgcanvas.html Event Handling 
> section could be extended.

    I'll see what I can do (unfortunately I'm not sure that the events
have particularly 'typical' usages).

> In general documentation is a problem of almost all free projects, but 
> to understand the complexity and great variety of functionality of batik 
> project, new tutorials and examples would be very helpful in the future. 
> Don't you think?

    Please feel free to submit titles for tutorials and examples.
    I honestly have a hard time coming up with good things to do
tutorials on.

To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org

View raw message