title: HSQLDB triggers OutOfMemoryError when using nested queries and the DB is in read-only mode
body: <p>For a complex use case with about 300000 queries we are using HSQLDB in read-only mode. After a short time, we run into an <code>OutOfMemoryError</code>.</p>
  
  <p>The problem is the combination of sub-select queries and read only, all other combinations work fine and fast:</p>
  
  <pre><code>               simple select   nested select
  DB read only   works           OOM
  DB read/write  works           works
  </code></pre>
  
  <p><a href="https://www.dropbox.com/s/oroicjk44bpvp2g/OOM-read-only-repro.zip" rel="nofollow noreferrer">Here</a> is a simple reproducer including a (read only) data base for the reproducer.</p>
  
  <p>To switch to a read/write DB, simple delete the line "readonly=true" in repo.properties and run the test again.</p>
  
  <p>I suspect that the <code>RowStoreAVLHybrid</code>class is part of the problem, because that class only is used in the subselect+read-only case.</p>
  
  <p>Any idea what i can do besides switching the database to read/write, what i want to avoid at all cost?</p>