When JVM is started OS allocates memory to it and then that memory is used as the heap and the stack. When we create an object in the heap, what happens to the object after the JVM exits? Does it quietly stay there and OS reallocates that memory when JVM restarts? Or does something else happen?
What happens to the Objects in the heap when JVM exits?
272 Views Asked by Shubhamhackz At
2
There are 2 best solutions below
0
Retro Gamer
On
Objects in the heap are freed when the JVM exits (most of the time).
The reason I say most of the time is because freeing the heap is the responsibility of the operating system, not the JVM alone. The operating system does the effort of cleaning up and making memory allocations available for leasing. But this also depends on the operating system, I'm sure there are operating systems out there where they don't follow this mainstream method.
Related Questions in OBJECT
- Getting Value from Object with Characters in Element Name
- Java: set and get methods for strings
- Angular populate select with object of objects
- Is it possible to have a command last only while the object is moving?
- Converting an unknown to an array in PHP
- Can anyone explain why this snippet of code is working in the constructor only?
- How to initialize an object with an array parameter in Java
- How can I assign initial data to some variables in literal object before use
- Check if a private function exists inside an object in JavaScript
- java.lang.ArrayIndexOutOfBoundsException object array
- Jquery object is undefined after sort but is in firebug
- Using NON static class Methods Without reference
- JSON-like object in Python
- Change value of each property in array of objects in javascript - map() method?
- Does Object.defineProperty has access the memory address of object?
Related Questions in MEMORY
- DataTable does not release memory
- Impala Resource Estimation for queries with Group by
- Is there any way to get a lru list in Linux kernel?
- C# console application - Unhandled exception while finding the Available and free Ram space.Getting exact answer in windows forms application
- Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in PHP
- C# equivalent of Java Memory mapping methods
- How to figure out the optimal fetch size for the select query
- Creating two arrays with malloc on the same line
- Using parse.com and having allocation memory issue
- error reading variable: cannot access memory at address
- CentOS memory availability
- Correct idiom for freeing repr(C) structs using Drop trait
- Find Ram/Memory manufacturer in Linux?
- Profiling memory usage on App Engine
- Access Violation: 0xC0000005, why is this happening?
Related Questions in JVM
- JVM is functioning very differently with same flags
- Heap size issue on migrating from Solr 5.0.0 to Solr 5.1.0
- Can't open eclipse with Windows 7 (doesn't see jdk jde)
- Can I import java libraries in HP ALM without Microsoft Java Virtual Machine?
- resin project, jdk8 has a high cpu load ,but jdk7 not
- Using multiple JVM languages in the same project
- Practical case JVM tunning to avoid full GC
- why does buckminster not resolve my passed JVM argument?
- Where to patch back the information gathered during program analysis
- Java 8 , JCE Unlimited Strength Policy and SSL Handshake over TLS
- Does the JVM limit the number of threads an Executor can run?
- With Swift open sourced, what would it take to have it running on the JVM?
- JVM ClassUnloadingWithConcurrentMark flag
- Ruby RJB can't create Java VM error
- Exposing whether an application is undergoing GC via UDP
Related Questions in HEAP-MEMORY
- C++ Pointer Object Location
- Interpretation of java hprof histogram
- Application Verifier limits Heap Allocations by default?
- How do I release images and avoid outOfMemory exc-n when navigating back and forth between activities[android]
- Is an attempt to modify a const_cast-ed, but dynamically allocated constant object still undefined behavior?
- Constant container (map) - eliminate heap allocation
- OutOfMemoryError: Java heap space MultipartRequest
- Predictionio evaluation fails with empty.maxBy exception and training with java.lang.OutOfMemoryError
- Two versions of the same java program out of which one is throwing Out of Memory Error and other one is not. Not able to get to know why?
- Heap - How free bytes are tracked?
- AngularJs $scope.$destroy(). How to use?
- Segmentation fault - Invalid free unresolved - C
- Query, if a heap is executable
- WA_DeleteOnClose delete all members?
- How to find the default Java 1.4.2 heap size in AIX
Related Questions in STACK-MEMORY
- C++ Pointer Object Location
- Deciding between datastore and global variables
- Error when attempting to use the heap
- Can RAM be conceptually divided into 'stack' and 'heap memory'?
- Can robovm allocate local method objects on the stack rather than heap?
- Where are the variable/reference names or types stored in memory for stack/heap variables?
- Structs on stack classes on heap
- Stack & Heap & Garbage Collector
- Memory structure for reference and value types
- Is it a bad manner to use the stack to avoid dynamic allocation?
- How to translate assembly to C with stack implemented on heap?
- what is this weird behavior in this c code?
- Is using Static better to memory management or not?
- What happens to the Objects in the heap when JVM exits?
- 'undefined' - if it's defined as a primitive value, what is it defined in terms of its value at the memory level?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Most objects simply "evaporate" when the JVM exits — i.e., they vanish without the normal garbage collection process (including finalization) taking place. (It is possible to request finalization for them, but it is unwise because they may still be reachable and in use.) If those objects represent OS resources like open files, those resources are released (closed), but without guaranteeing that all outstanding data is saved (as happens when you close them yourself).
More generally, when a process exits, all of its normal stack and heap memory is immediately freed by the OS (although some of it, like that used to store the executable and other files that were read, can sometimes be reused (or left in use) for other processes that need those files). Exceptions include things like shared memory used for interprocess communication, which you're probably not using without knowing it.