Skip to content

Commit 78f7eaa

Browse files
authored
Create GarbageCollection.java
1 parent 5d7d8d3 commit 78f7eaa

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

GarbageCollection.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Program to Demonstrate Garbage Collection
2+
3+
import java.util.*;
4+
class GarbageCollection
5+
{
6+
public static void main(String args[]) throws Exception
7+
{
8+
Runtime rs = Runtime.getRuntime();
9+
System.out.println("Free Memory in JVM before Garbage Collection :- "+rs.freeMemory());
10+
rs.gc();
11+
System.out.println("Free Memory in JVM after Garbage Collection :- "+rs.freeMemory());
12+
}
13+
}

0 commit comments

Comments
 (0)