switch back to enhanced causes exception

This forum is to report technical problems with Rel.
Post Reply
HughDarwen
Posts: 121
Joined: Sat May 24, 2008 4:49 pm

switch back to enhanced causes exception

Post by HughDarwen »

Sorry about this--it appears to be an "out of memory" exception, perhaps caused by an unreasonably large query result. I'm sure I can live with "no action", if necessary, but I'd like to know your position and policy regarding such problems.

With "Enhanced" turned on, I successfuly entered the query, BirdTrack, giving a result of cardinality 3084, degree 4. Turning off Enhanced now worked fine and I saw the relation literal representation of the result. However, turning Enhanced back on now gave the exception shown below, in the window titled "DBrowser" (not the one I think of as the DBrowser window, which is titled "Rel - DBrowser"). This is with Version 0.3.8 but it happened yesterday too, with 0.3.7. It's a bit inconvenient when it first happens, because the window showing the exception is minimised and the Rel - DBrowser window just stops responding, making me think it's merely taking a long time to rebuild the tabular display!

Hugh
Opening database: S:\Rel\V3\
Database S:\Rel\V3\ open.
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap spa
ce
Dave
Site Admin
Posts: 368
Joined: Sun Nov 27, 2005 7:19 pm

Re: switch back to enhanced causes exception

Post by Dave »

I have been able to duplicate this problem.

There appears to be a memory leak in DBrowser. When "Enhanced" is switched from enhanced to non-enhanced and back again, it seems the original enhanced display (or its contents) is retained in memory. A relation of relatively high cardinality turns into a large table in the enhanced display, which apparently consumes a lot of memory. Unfortunately, I'm not yet sure whether this memory leak is within my DBrowser code or inside the Java library class that displays the tabular view.

I'll work on a fix.

As a short-term workaround, you can alter DBrowser.bat to increase the amount of memory available to Java. The file currently contains the following line:

Code: Select all

java -jar DBrowser.jar
Change it to:

Code: Select all

java -jar -Xms32m -Xmx256m DBrowser.jar
This tells Java it can have up to 256 megabytes for its heap, double the 128 megabyte default. The amount (specified in '-Xmx256m') can be increased beyond 256 if you have plenty of available RAM.

Unfortunately, out-of-memory errors are difficult to handle in a user-friendly fashion. When they occur, any mechanisms that might usefully display the error -- such as a pop-up window -- are probably damaged. However, I'll see what I can do about this as well.
Dave
Site Admin
Posts: 368
Joined: Sun Nov 27, 2005 7:19 pm

Re: switch back to enhanced causes exception

Post by Dave »

Some further information on this...

I've fixed the bug in switching from enhanced to non-enhanced and back. It no longer leaks memory, and the fix will be available in the version 0.3.9 update.

However, in testing this I've found that the Java library mechanisms used to display enhanced output consume an amount of memory way out of proportion to the memory consumed by their non-enhanced equivalent. A relation that can be described in a few hundred kilobytes of un-enhanced text will consume many megabytes of enhanced display. This means DBrowser can run out of memory when it attempts to display a relation with a cardinality as little as 10,000 with degree 4. It also can occur if the output window is allowed to fill without being cleared. Unfortunately, Java is notoriously poor at dealing with low-memory situations -- it tends to crash rather than recover gracefully when the condition is detected.

In the short term, the solution may be to avoid enhanced display relations of relatively high cardinality, and make sure the "enhanced" display is cleared regularly. :roll:

In the long term, I think I'll have to replace the current enhanced display with something more sophisticated, such as a display that retrieves and presents (say) at most 1000 tuples, but allows the user to "page" through a high-cardinality relation 1000 tuples at a time.
HughDarwen
Posts: 121
Joined: Sat May 24, 2008 4:49 pm

Re: switch back to enhanced causes exception

Post by HughDarwen »

Thank you, Dave. I was expecting a reply of this sort. The problem doesn't bother me greatly and I can live with it.

Hugh
Post Reply