FLTK logo

STR #3368

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 Home  |  Articles & FAQs  |  Bugs & Features  |  Documentation  |  Download  |  Screenshots  ]

Return to Bugs & Features | Post Text | Post File | SVN ⇄ GIT | Prev | Next ]

STR #3368

Application:FLTK Library
Status:5 - New
Priority:2 - Low, e.g. a documentation error or undocumented side-effect
Scope:3 - Applies to all machines and operating systems
Subsystem:Core Library
Summary:Fl_Help_View may leak memory when images are in the HTML
Created By:chris
Assigned To:Unassigned
Fix Version:Unassigned
Update Notification:

Receive EMails Don't Receive EMails

Trouble Report Files:

Post File ]
Name/Time/Date Filename/Size  
#1 chris
11:55 Mar 20, 2017

Trouble Report Comments:

Post Text ]
Name/Time/Date Text  
#1 chris
01:50 Mar 17, 2017
When a Fl_Help_View contains images these are loaded via Fl_Shared_Image::get(). When the view is deleted these images are not always (*) unloaded from memory. This can be observed with the 'help_dialog' demo: Listing the shared memory array after the 'delete help' shows there are still images in memory.

The cause is that images sometimes get loaded twice during the initial load, so their refcount is 2, and when releasing them at deletion of the help view they are not deleted.

(*) I found two cases:
- images in a table seem to get loaded twice always (as in help_demo).
- when an image is encaountered during format() that is broader than the "current" width, the format loop is re-done and images get loaded again.
#2 chris
01:55 Mar 17, 2017
> listing the shared memory array..
This should read: listing the shared images array..

Like that:

svn diff help_dialog.cxx
Index: help_dialog.cxx
--- help_dialog.cxx (Revision 12188)
+++ help_dialog.cxx (Arbeitskopie)
@@ -65,6 +65,14 @@

   delete help;

+  int n = Fl_Shared_Image::num_images();
+  for ( int i = 0; i < n; i++ )
+  {
+    Fl_Shared_Image *img = Fl_Shared_Image::images()[i];
+    printf( "%d: %s %d x %d ref=%d\n", i + 1, img->name(), img->w(),
img->h(), img->refcount() );
+  }
#3 chris
11:58 Mar 20, 2017
Posting a possible simple solution: Memorize how far parsing in format() already came before re-parsing and load images only 'initial' when beyond that point (again).  

Return to Bugs & Features | Post Text | Post File ]


Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.