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

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>7172</bug_id>
          
          <creation_ts>2009-07-30 08:10:07 +0000</creation_ts>
          <short_desc>Memory leak: TesterConfiguration kept in threads local storage once thread is over</short_desc>
          <delta_ts>2009-08-04 13:48:39 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>mobileOK Basic checker</product>
          <component>Java Library</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="fd">fd</reporter>
          <assigned_to name="fd">fd</assigned_to>
          
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>26134</commentid>
    <comment_count>0</comment_count>
    <who name="fd">fd</who>
    <bug_when>2009-07-30 08:10:07 +0000</bug_when>
    <thetext>Problem
-----
The configuration of the Checker is set as a per-thread singleton using Thread local storage. The Checker uses multithreading though, and references to the initial singleton are thus made in each of the thread created to check a given URI.

Upon termination of the preprocessing, the Thread instances seem to return to a global static pool that is controlled by the JVM. The instances keep the reference to the the TesterConfiguration instance as long as they haven&apos;t been re-used.

No consequence when the Checker is run once on a given URI, as the whole process is killed at the end. It is a major problem though when the Checker is to stay in memory: the TesterConfiguration instance now contains references to most of the structures created during preprocessing and thus may require an awful lot of memory. When 50-100 instances of TesterConfiguration are in memory, OutOfMemory exceptions start to show up.


Solution
-----
The best solution would be to get rid of the per-thread singleton but that would require a fair amount of changes. A simple solution is to reset the per-thread TesterConfiguration singleton at the end of each thread.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26137</commentid>
    <comment_count>1</comment_count>
    <who name="fd">fd</who>
    <bug_when>2009-07-30 08:59:22 +0000</bug_when>
    <thetext>The Preprocessor class now is in charge of setting and then resetting the TesterConfiguration instance in processResource (main method of a Runnable thread).

Similar code to set the configuration in the Resource class was removed, as it&apos;s not needed anymore.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26145</commentid>
    <comment_count>2</comment_count>
    <who name="fd">fd</who>
    <bug_when>2009-07-30 16:00:38 +0000</bug_when>
    <thetext>Call to shutdown() on the ExecutorService thread pool added at the end of  Preprocessor.preprocess as well, so that Thread instances may be garbage collected as well.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>