<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://jogamp.org/bugzilla/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.2"
          urlbase="https://jogamp.org/bugzilla/"
          
          maintainer="sgothel@jausoft.com"
>

    <bug>
          <bug_id>1029</bug_id>
          
          <creation_ts>2014-07-08 12:44:37 +0200</creation_ts>
          <short_desc>Memory leak in GLDrawableHelper: &apos;perThreadInitAction&apos; shall use a WeakReference</short_desc>
          <delta_ts>2014-07-29 04:06:35 +0200</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>JogAmp</classification>
          <product>Jogl</product>
          <component>opengl</component>
          <version>2</version>
          <rep_platform>All</rep_platform>
          <op_sys>all</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>---</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Bart Adams">bart.adams</reporter>
          <assigned_to name="Sven Gothel">sgothel</assigned_to>
          <cc>askinner</cc>
          
          <cf_type>---</cf_type>
          <cf_scm_refs>876a168f6757454e8a02543b53e32b89e54282bd</cf_scm_refs>
          <cf_workaround>---</cf_workaround>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>4010</commentid>
    <comment_count>0</comment_count>
    <who name="Bart Adams">bart.adams</who>
    <bug_when>2014-07-08 12:44:37 +0200</bug_when>
    <thetext>GLDrawableHelper keeps a ThreadLocal variable:

private static final ThreadLocal&lt;Runnable&gt; perThreadInitAction = new ThreadLocal&lt;Runnable&gt;();

The init action in GLCanvas and GLJPanel are defined as anonymous classes (hence keeping a reference to the canvas or panel itself).

It looks like these init actions are kept in above ThreadLocal variable, even after disposing the GLCanvas or GLJPanel, leading to a memory leak as long as the ThreadLocal variable keeps the runnable.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4036</commentid>
    <comment_count>1</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2014-07-28 00:48:44 +0200</bug_when>
    <thetext>Commit 876a168f6757454e8a02543b53e32b89e54282bd:

Static ThreadLocal &apos;perThreadInitAction&apos; leaks memory if using a hard reference,
utilizing a WeakReference allows the passed &apos;initAction&apos; owner to be garbage collected.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4042</commentid>
    <comment_count>2</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2014-07-29 04:06:35 +0200</bug_when>
    <thetext>Note-1:

It has to be noted, that the static ThreadLocal storage 
within GLDrawableHelper originally did not get released 
in case of AWT, since the GLDrawableHelper instance is 
a member of GLCanvas/GLJPanel and used from within the 
AWT-EDT, which does not die.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>