Question: 1 -
Which of the below is not a memory leak solution?
-
GC parameter tuning
-
JVM parameter tuning
-
Process restart
-
Code changes
Answer:
Process restart
Solution:
Process restart is not a permanent fix to memory leak problem. The problem will resurge again.
Process restart is not a permanent fix to memory leak problem. The problem will resurge again.
Question: 2 -
What is -Xms and -Xmx while starting jvm?
-
Initial memory
-
Initial; Maximum memory
-
Maximum; Initial memory
-
Maximum memory
Answer:
Initial; Maximum memory
Solution:
JVM will be started with Xms amount of memory and will be able to use a maximum of Xmx amount of memory. java -Xmx2048m -Xms256m.
JVM will be started with Xms amount of memory and will be able to use a maximum of Xmx amount of memory. java -Xmx2048m -Xms256m.
Question: 3 -
Which of the below is not a Java Profiler?
-
JConsole
-
JProfiler
-
Eclipse Profiler
-
JVM
Answer:
JVM
Solution:
Memory leak is like holding a strong reference to an object although it would never be needed anymore. Objects that are reachable but not live are considered memory leaks. Various tools help us to identify memory leaks.
Memory leak is like holding a strong reference to an object although it would never be needed anymore. Objects that are reachable but not live are considered memory leaks. Various tools help us to identify memory leaks.
Question: 4 -
What allows the programmer to destroy an object x?
-
Runtime.getRuntime().gc()
-
Only the garbage collection system can destroy an object
-
x.delete()
-
x.finalize()
Answer:
Only the garbage collection system can destroy an object
Solution:
When an object is no longer referenced, it may be reclaimed by the garbage collector. If an object declares a finalizer, the finalizer is executed before the object is reclaimed to give the object a last chance to clean up resources that would not otherwise be released. When a class is no longer needed, it may be unloaded.
When an object is no longer referenced, it may be reclaimed by the garbage collector. If an object declares a finalizer, the finalizer is executed before the object is reclaimed to give the object a last chance to clean up resources that would not otherwise be released. When a class is no longer needed, it may be unloaded.
Question: 5 -
How to get prints of shared object memory maps or heap memory maps for a given process?
-
memorypath
-
memorymap
-
jvmmap
-
jmap
Answer:
jmap
Solution:
We can use jmap as jmap -J-d64 -heap pid.
We can use jmap as jmap -J-d64 -heap pid.