From: Werner S. <sm...@ia...> - 2010-01-22 14:12:54
|
Hi Hans, On 1/22/10 2:28 PM, Han...@sh... wrote: > Werner, > > Putting the pladv before the plclear will not help me, as I have > users that plot a lot on (part of) the same plot, so no plclear is > done and the plot buffer will keep on growing. Ok, I agree I still don'tunderstand. I need more information. Which driver do you use wxWidgets or xwin? Are both plots on the same page/plstream? If so and you use plclearbuf(), the buffer would be corrupt, since the colour bar wouldn't be replotted any more, or? Especially if you copy the stream, or? Do you need the plplot buffer? E.g. the wxWidgets driver needs it so that windows can be resized. If there are two different streams (one for the bar, one for the contour plot) then you could just use pladv() on the contour plot (and replot the axis as well). > > So in that case (when users not have requested to make a hardcopy > later), I want to keep the plot buffer as small as possible, thus > clearing it before the next plot is done. But this is done with pladv(0) as well. > > May be an example is better. In the attached you see a (for PlPlot 1 > window) 2 seperate windows, 1 is the colour bar and the other the > contour map. Now users refresh continuously the contour map but not > the colour bar, so a plclear cannot be done, but a clear of the plot > buffer can be done. So you just plot above the old plot? So you call only plshade or something like that again? Regards, Werner > > I appreciate that a new API is not very wanted, but I don't see > another way of keeping the plot buffer small. > > Hope this calrifies it a bit. > > Regards, Hans > > -----Original Message----- From: Werner Smekal > [mailto:sm...@ia...] Sent: Friday, January 22, 2010 > 09:08 To: Rijneke, Hans H SIEP-EPT-RIS Cc: rob...@jk...; > PLplot development list Subject: Re: [Plplot-general] How to clear > the plot buffer of awxPLplotwindow? > > > 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, Han...@sh... 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:rob...@jk...] Sent: Friday, April 03, 2009 15:31 >> To: Werner Smekal Cc: plp...@li... 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 Plp...@li... >> 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: sm...@ia... 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 |