On Thu, Mar 19, 2015 at 09:08:21AM +0000, Andrew Ross wrote:
>
> > The attached patch fixes the memory leak for me. Pressing the close button
> > should now behave the same as pressing 'Q', i.e. it will abort the
> > program and clean up correctly. It looks like this was changed at some
> > stage in the past, but I don't know why. I guess this would allow a
> > programme to continue, and to potentially reopen a new xwin window. If we
> > want to retain this functionality it will require a bit more thinking
> > about.
>
> Thinking some more about this, I seem to recall the change was made
> because of interactive bindings. For example, if you are using octave and
> pressed the close button then the call to plabort would kill your entire
> octave session which is clearly not desirable. We definitely don't want to
> apply my patch as is. I need to work through all the tidy up code in
> xwin.c to check exactly the path that is being followed. The current code
> is doing the right thing in terms of closing the window and ignoring all
> further commands to the plplot stream, we just need to ensure that the
> tidy function is called at the end. A clean way of doing this would be to
> have multiple levels of stream_closed. 0 = open, 1 = closed, but still
> need to call tidy, 2 = closed and tidy already called.
>
> Only the xwin and cairo drivers set this flag, but it is checked in the
> core plplot code. I can simply implement this change Alan, but your call
> whether you want to commit it at this late stage. It should be trivial.
Further thought showed the patch was even simpler. Since only the xwin and
xcairo drivers change stream_closed, and then only when the close button
is pressed, we don't need the check of if ( ! stream_closed ) around the
call to plD_tidy. This change now removes the extra valgrind leaks when
using the close button for xwin / xcairo drivers. There are still a good
number of other leaks to investigate, but I suspect these are library
related. I have tested this with and without dynamic drivers, and also
checked no adverse affects on our clear psc results.
Alan - your call whether to apply this or not. I am pretty confident that
this will not have adverse effects, but I would like testing by others.
Andrew
>From 639ed78612c786589c0e5c2d302f8e3bd677c782 Mon Sep 17 00:00:00 2001
From: Andrew Ross <andrewr...@users.sourceforge.net>
Date: Thu, 19 Mar 2015 09:27:52 +0000
Subject: [PATCH] Fix bug where plD_tidy_* routine wasn't closed if the xwin /
xcairo drivers were exited using the close button.
---
src/plcore.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/src/plcore.c b/src/plcore.c
index 6f03420..4bcc24c 100644
--- a/src/plcore.c
+++ b/src/plcore.c
@@ -231,10 +231,7 @@ plP_tidy( void )
}
save_locale = plsave_set_locale();
- if ( !plsc->stream_closed )
- {
- ( *plsc->dispatch_table->pl_tidy )( (struct PLStream_struct *) plsc );
- }
+ ( *plsc->dispatch_table->pl_tidy )( (struct PLStream_struct *) plsc );
plrestore_locale( save_locale );
if ( plsc->plbuf_write )
--
2.1.0
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel