title: Disposing of Textures not fully working libgdx java
body: <p>I am trying to completely dispose of all Textures in my asset manager and return the memory usage to where it started. I made a very simple test program to try using a static class called AssetManager, fill with 1000 Textures, and then dispose all of them. My goal is to reach the memory usage of where it started. When I run the program I am using 35 megabytes. I then click enter to populate the list and the program reaches roughly 500 megabytes. I then click space to clear and the program then runs at 65 megabytes. Nearly DOUBLE of what I started at! Here is the test AssetManager class called Test</p>
  
  <pre><code>    public class Test {
  
  public static Hashtable&lt;String, Texture&gt; textureList = new Hashtable&lt;String, Texture&gt;();
  
  public static void put(String key, Texture texx){
      textureList.put(key, texx);
  }
  
  public static Texture getTexture(String key){
      return textureList.get(key);
  }
  
  public static void stressTest(int lim){
      for(int i = 0; i &lt; lim; i++){
          textureList.put("Texture: " + i, new Texture(Gdx.files.internal("badlogic.jpg")));
      }
  }
  public static void destroy(String key){
      textureList.remove(key);
  }
  
  public static void dispose(){
      for(int i = 0; i &lt; textureList.size(); i++)
          textureList.get("Texture: " + i).dispose();
      textureList.clear();
  }
  
  public static int poolSize(){
      return textureList.size();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and here is the rendering method of the main class</p>
  
  <pre><code>    if(Gdx.input.isKeyJustPressed(Keys.SPACE)){
          Test.dispose();
      }
      if(Gdx.input.isKeyJustPressed(Keys.ENTER)){
          Test.stressTest(1000);
      }
      Gdx.gl.glClearColor(0, 0, 0, 1);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
      batch.begin();
      if(Test.poolSize() &gt; 1)
      for(int i = 0; i &lt; Test.poolSize(); i++){
          batch.draw(Test.getTexture("Texture: " + i), i, i, 10, 10);
      }
      batch.end();
  </code></pre>
  
  <p>Any help with this would be huge because my main program is a mining game, which you can imagine is a lot of disposing textures. Also please don't suggest reusing one texture as there are over 1500 <em>different</em> textures in my main game.</p>
  
  <p>**Question: ** How do I completely dispose of Textures so that I reach my original memory usage of 35 megabytes</p>