title: @@@ ABORTING: INVALID HEAP ADDRESS IN dlfree addr=0x00000156
body: <p>I have begun to try and keep some data persistant in my views when my device is rotated. Since implementing this after awhile my app will crash with the error:</p>
  
  <pre><code>@@@ ABORTING: INVALID HEAP ADDRESS IN dlfree addr=0x00000156
  Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 20787 (FinalizerDaemon)
  </code></pre>
  
  <p>After the app crashed every time I try to reopen it i get this same error instantly until I uninstall the app.</p>
  
  <p>Does anyone know what causes this error?</p>
  
  <p>Here is the code I used to save my data:</p>
  
  <p><strong><code>onDestory()</code>:</strong></p>
  
  <pre><code>    System.out.println("Saving");
      ArrayList&lt;Path&gt; strokes = paintCanvas.strokes;
      ArrayList&lt;Integer&gt; colors = paintCanvas.colors;
      SharedPreferences settings = getSharedPreferences("colors", MODE_PRIVATE);
      settings.unregisterOnSharedPreferenceChangeListener(listener);
  
  
  
      /**Write Colors**/
      try
      {
          FileOutputStream os = openFileOutput("drawing.dat", MODE_PRIVATE);
          ObjectOutputStream output = new ObjectOutputStream(os);
          output.writeObject(colors);
          output.close();
      }
      catch (Exception e)
      {
          e.printStackTrace();
      }
  
      /**Write Paths**/
      try
      {
  
          Gson gson = new Gson();
  
          File file = getFileStreamPath("paths.txt");
          FileWriter writer = new FileWriter(file);
          BufferedWriter output = new BufferedWriter(writer);
          for(Path p : strokes)
          {
              String s = gson.toJson(p);
              s = s + "\n";
              output.write(s);
          }
  
          output.close();
      }
      catch (Exception e)
      {
          e.printStackTrace();
          //System.out.println(e.getMessage());
      }
  </code></pre>
  
  <p><strong>In <code>onCreate()</code>:</strong></p>
  
  <pre><code>    //Try Load here!
      /**Read Colors**/
      try
      {
          ArrayList&lt;Integer&gt; colors;
          ArrayList&lt;Path&gt; strokes;
          FileInputStream ins = openFileInput("drawing.dat");
          ObjectInputStream reader = new ObjectInputStream(ins);
          colors = (ArrayList&lt;Integer&gt;)reader.readObject();
  
          paintCanvas.colors = colors;
          System.out.println("Colors Loaded");
      }
      catch (Exception e)
      {
          e.printStackTrace();
      }
  
      /**Read Paths**/
      try
      {
          FileInputStream fis = openFileInput("paths.txt");
          InputStreamReader isr = new InputStreamReader(fis);
          BufferedReader bufferedReader = new BufferedReader(isr);
          StringBuilder sb = new StringBuilder();
          String line;
          Gson gson = new Gson();
  
          ArrayList&lt;Path&gt; paths = new ArrayList&lt;Path&gt;();
          while ((line = bufferedReader.readLine()) != null)
          {   
              paths.add(gson.fromJson(line,Path.class));
          }
  
  
          paintCanvas.strokes = paths;
          paintCanvas.currentStroke = paintCanvas.strokes.size() - 1;
          System.out.println("Paths Loaded");
      }
      catch (Exception e)
      {
          e.printStackTrace();
      }
  </code></pre>