From: gmungoc Date: Wed, 13 Sep 2017 09:02:31 +0000 (+0100) Subject: JAL-2727 alignment width and height tailored to this test X-Git-Tag: Release_2_10_3b1~74^2~3 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=8b21c13f49da87d7f13ec5efa3d7b4054aa3fd5f JAL-2727 alignment width and height tailored to this test --- diff --git a/test/jalview/gui/FreeUpMemoryTest.java b/test/jalview/gui/FreeUpMemoryTest.java index 2a9a8c9..9fc0678 100644 --- a/test/jalview/gui/FreeUpMemoryTest.java +++ b/test/jalview/gui/FreeUpMemoryTest.java @@ -17,7 +17,7 @@ import org.testng.annotations.Test; public class FreeUpMemoryTest { - private static final int ONE_MB = 1024 * 1024; + private static final int ONE_MB = 1000 * 1000; /** * Configure (read-only) Jalview property settings for test @@ -75,21 +75,27 @@ public class FreeUpMemoryTest af.closeMenuItem_actionPerformed(true); /* - * request garbage collection and allow 1 second for it to complete; - * NB there is no guarantee when, or whether, it will run! + * request garbage collection and wait briefly for it to run; + * NB there is no guarantee when, or whether, it will do so */ System.gc(); synchronized (this) { try { - wait(1000); + wait(10); } catch (InterruptedException e) { } } /* + * a second gc() call should not be necessary - but it is! + * the test passes with it, and fails without it + */ + System.gc(); + + /* * check used memory is 'reasonably low' */ long availableMemory = Runtime.getRuntime().totalMemory() / ONE_MB; @@ -105,9 +111,10 @@ public class FreeUpMemoryTest * - identify large objects in the heap and their referers * - fix code as necessary to null the references on close */ - long expectedMax = 100L; - assertTrue(usedMemory < expectedMax, - String.format("Used memory %d > %d", usedMemory, expectedMax)); + long expectedMax = 30L; // typically reports around 25 + assertTrue(usedMemory < expectedMax, String.format( + "Used memory %d should be less than %d", usedMemory, + expectedMax)); } /** @@ -129,8 +136,11 @@ public class FreeUpMemoryTest } /** - * Generates an alignment (large enough for this test but not so large it is - * too slow or runs out of memory) and saves it in a temporary file. + * Generates an alignment and saves it in a temporary file, to be loaded by + * Jalview. We use a peptide alignment (so Conservation and Quality are + * calculated), which is wide enough to ensure Consensus, Conservation and + * Occupancy have a significant memory footprint (if not removed from the + * heap). * * @return * @throws IOException @@ -140,7 +150,9 @@ public class FreeUpMemoryTest File f = File.createTempFile("MemoryTest", "fa"); PrintStream ps = new PrintStream(f); AlignmentGenerator ag = new AlignmentGenerator(false, ps); - ag.generate(1000, 20000, 0, 10, 15); + int width = 100000; + int height = 100; + ag.generate(width, height, 0, 10, 15); return f; } }