Skip to content

Commit 612b9a1

Browse files
maibinEugen
authored andcommitted
Updated guest article (eugenp#2189)
* Create memory-leaks module * Memory Leaks * Added str.intern() * Memory Leaks updated * Updated guest article * Memory Leaks update * Remove unused resource * Updated Memory Leaks Article
1 parent 716e7c2 commit 612b9a1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

guest/memory-leaks/src/test/java/com/baeldung/MemoryLeaksTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
// for (int i = 0; i < 1000000; i++) {
3535
// list.add(random.nextDouble());
3636
// }
37+
// System.gc();
3738
// Thread.sleep(10000); //to allow GC do its job
3839
// }
3940
//
@@ -54,11 +55,13 @@
5455
//
5556
// @SuppressWarnings({ "resource" })
5657
// @Test(expected = OutOfMemoryError.class)
57-
// public void givenLengthString_whenIntern_thenOutOfMemory() throws IOException {
58+
// public void givenLengthString_whenIntern_thenOutOfMemory() throws IOException, InterruptedException {
59+
// Thread.sleep(15000);
5860
// String str = new Scanner(new File("src/test/resources/large.txt"), "UTF-8").useDelimiter("\\A")
5961
// .next();
62+
// System.gc();
6063
// str.intern();
61-
// System.out.println("Done");
64+
// Thread.sleep(10000);
6265
// }
6366
//
6467
// @Test(expected = OutOfMemoryError.class)

0 commit comments

Comments
 (0)