@@ -2182,32 +2182,39 @@ Some tools that do memory management to identifies useless objects or memeory le
2182
2182
* <a href =" http://www.javaperformancetuning.com/tools/jprobe/index.shtml " >JProbe</a >
2183
2183
* <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 >
2184
2184
2185
+ ** Example:**
2186
+
2185
2187
``` 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
+ }
2197
2201
```
2202
+
2198
2203
Output
2199
- ```
2204
+
2205
+ ``` java
2200
2206
Exception in thread " main" java.lang. OutOfMemoryError : Java heap space exceed
2201
2207
```
2202
2208
2203
- ** Types of Memory Leaks in Java**
2209
+ ** Types of Memory Leaks in Java: **
2204
2210
2205
2211
* Memory Leak through static Fields
2206
2212
* Unclosed Resources/connections
2207
2213
* Adding Objects With no ` hashCode() ` and ` equals() ` Into a HashSet
2208
2214
* Inner Classes that Reference Outer Classes
2209
2215
* Through ` finalize() ` Methods
2210
2216
* Calling ` String.intern() ` on Long String
2217
+
2211
2218
<div align =" right " >
2212
2219
<b><a href="#related-interview-questions">↥ back to top</a></b>
2213
2220
</div >
0 commit comments