Skip to content

Commit 31677ab

Browse files
committed
Update README.md
1 parent 525b7a4 commit 31677ab

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

README.md

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,32 +2182,39 @@ Some tools that do memory management to identifies useless objects or memeory le
21822182
* <a href="http://www.javaperformancetuning.com/tools/jprobe/index.shtml">JProbe</a>
21832183
* <a href="https://www.ibm.com/support/knowledgecenter/en/SSTFXA_6.3.0/com.ibm.itm.doc_6.3/install/itm_over.htm">IBM Tivoli</a>
21842184

2185+
**Example:**
2186+
21852187
```java
2186-
// Java Program to illustrate memory leaks
2187-
import java.util.Vector;
2188-
public class MemoryLeaksDemo
2189-
{
2190-
public static void main(String[] args) {
2191-
Vector v = new Vector(214444);
2192-
Vector v1 = new Vector(214744444);
2193-
Vector v2 = new Vector(214444);
2194-
System.out.println("Memory Leaks Example");
2195-
}
2196-
}
2188+
/**
2189+
* Memory Leaks
2190+
*/
2191+
import java.util.Vector;
2192+
2193+
public class MemoryLeaksExample {
2194+
public static void main(String[] args) {
2195+
Vector v = new Vector(214444);
2196+
Vector v1 = new Vector(214744444);
2197+
Vector v2 = new Vector(214444);
2198+
System.out.println("Memory Leaks Example");
2199+
}
2200+
}
21972201
```
2202+
21982203
Output
2199-
```
2204+
2205+
```java
22002206
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space exceed
22012207
```
22022208

2203-
**Types of Memory Leaks in Java**
2209+
**Types of Memory Leaks in Java:**
22042210

22052211
* Memory Leak through static Fields
22062212
* Unclosed Resources/connections
22072213
* Adding Objects With no `hashCode()` and `equals()` Into a HashSet
22082214
* Inner Classes that Reference Outer Classes
22092215
* Through `finalize()` Methods
22102216
* Calling `String.intern()` on Long String
2217+
22112218
<div align="right">
22122219
<b><a href="#related-interview-questions">↥ back to top</a></b>
22132220
</div>

0 commit comments

Comments
 (0)