Hi Hans (also be posted on list again),

I had a look yesterday evening in the plplot code about that issue and
found, that I already was working on a solution and remembered that it
was not that easy and that I wanted to have a closer look. Thinking
about that issues during the night ;), I've come to a conclusion and
post it to the list, so that others can share their opinion as well.

First the status quo:

plclear() clears the background in the current background color. IF the
driver supports clearing of the background an escape sequence is sent to
the driver and the driver takes care of the background clearing. At the
same time such an escape sequence is buffered (for replotting). If the
driver doesn't support that, plplot draws a filled rectangle above the
plot area. As far as I understand it, this function should mainly be
used to clear a plot on a multiple plot page (but works also if you have
a single plot).

pladv() lets you choose which plot on a multiple plot page you want plot
into, OR lets you advance to the next page (if you use pladv(0)).
pladv() itself calls pleop() (end of page) and plbop() (begin of page).

So now to the solution (actually no code change is needed):

plclear is not really meant to be starting a new plot. It's mainly about
clear one plot in a mulitple plot page or have a defined background for
a single plot page (not all drivers clear the background during
plbop()). Therefor it's more or less correct, that the buffer is plbuf.c
is not reset. Also since some drivers don't support clearing the
background via escape codes (and then a filled rectangle is drawn) it's
also difficult to reset the buffer for this call (since the buffer code
will only be called to draw a rectangle e.g. for the xwin driver - how
should it know to reset the buffer?).

On the other hand pladv() takes care about resetting the buffer, since
this is done in plbuf_bop() which is called by pladv().

I played a lot now with pladv() and plclear() in example 8 with
different drivers and my conclusion is, that if you want to make a new
plot in an existing stream you must use pladv(0) and to make sure, that
the background is in the color you want use a subsequent plclear(). This
should reset the buffer and you can start a new plot - memory problems
shouldn't occur then.

Hans, I'm not sure, but you're using only plclear(), or? Could you add
pladv(0) in front of that command? Removing you plclearbuf() commands -
does this solve you memory problems as well?

If yes, we should add a note to the documentation of plclear(), that
starting a new plot should be done with pladv() in order to prevent
memory problems.

HTH,
Werner



On 1/21/10 1:16 PM, hans.rijn...@shell.com wrote:
> Werner,
> 
> I write this e-mail to you as you were the last one responding on this 
> subject.
> 
> First my problem : I am getting more and more users suffering from PlPlot 
> being to memory hungry after several big plots and finally crashing or the 
> program or the machine itself.
> 
> Then I remembered the response from Robert requesting a clearall function and 
> as I know exactly in my program when I may erase all contents of the actual 
> plot buffer, I looked a little bit through the code and implemented a 
> "plclearbuf" function that just free's the plot buffer and allocates it with 
> the start value again (which I also increased by a factor of 10).
> 
> I added this call in my program and am glad to say that I no longer suffer 
> from the memory problems. Moreover plotting has become much and much faster.
> I had a test that finally failed after 55 minutes and with my updates I am 
> able to do the same (and just continue to do more) in just over 4 minutes. 
> This has probably to do with the realloc of growing and growing memory in the 
> "old" version whereas with this update my memory is "cleaned" regularly.
> 
> I am not sure if I implemented it all correctly (probably not), but for me it 
> works fine.
> 
> Is it possible for someone - who has a better insight in PlPlot - to check my 
> updates and may be imlemented it officially in PlPlot ?
> 
> Attached is the (small) list of updates I applied (I did it in PlPlot 5.9.2, 
> but don't think it will be different in the latest release).
> 
> Regards,
> Hans Rijneke
> 
> -----Original Message-----
> From: Robert Pollak [mailto:robert.pol...@jku.at]
> Sent: Friday, April 03, 2009 15:31
> To: Werner Smekal
> Cc: plplot-gene...@lists.sourceforge.net
> Subject: Re: [Plplot-general] How to clear the plot buffer of
> awxPLplotwindow?
> 
> 
> Hi Werner,
> 
> you wrote:
>>> Since I now have to update a plot very often and over long time, 
>>> let me ask whether the plot buffer can be cleared to avoid the 
>>> memory hogging, short of deleting/recreating the wxPLplotwindow.
>>
>> [...] unfortunately the fix for this is not that easy. If you have 
>> only one subwindow, then it would be ok to clear the buffer if 
>> pladv() is called. But this is not true if you have 2 or more 
>> subwindows. Clearing one subwindow with e.g. pladv(1) doesn't mean 
>> that you want to clear the other subwindows, what would happen if you
>> clear the buffer. This might be no problem for your case, but we 
>> would break the library for all who use subwindows. The fix I have in
>> mind is to split the buffers depending in what subwindow we plot. 
>> [...] it will need some time (say weeks to months) [...]
> 
> I understand. Would it be possible to introduce a "plclearall" function
> for my use case, which clears all subwindows? This would certainly be
> much easier.
> 
> --Robert
> 
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Plplot-general mailing list
> plplot-gene...@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/plplot-general
> 

-- 
Dr. Werner Smekal
Institut fuer Angewandte Physik
Technische Universitaet Wien
Wiedner Hauptstr 8-10
A-1040 Wien
Austria
DVR-Nr: 0005886

email: sme...@iap.tuwien.ac.at
web:   http://www.iap.tuwien.ac.at/~smekal
phone: +43-(0)1-58801-13463 (office)
       +43-(0)1-58801-13469 (laboratory)
fax:   +43-(0)1-58801-13499

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to