I know how roots are found, but the thing is, (AFAIK) they have to be found at runtime. For that, you'll need a fixed size container that may overflow or a resizable container. I don't want to go with the fixed size container because it would not be easy to tell how much space to reserve (and it may be wasteful). The resizable container seems best, but the problem is, the GC runs when there is not enough space, so the resizable container won't be able to store what it needs to. So with these conditions, how are GC roots stored?
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 COMPILER-CONSTRUCTION
- Is the compiler Xcode uses to produce Assembly code a bad compiler?
- How do compilers store hundreds of variables in only a few registers?
- Where to patch back the information gathered during program analysis
- Assignment Insertion in ROSE compiler after AssignOp
- memory layout of a multiple-inherited object in C++
- How to use my written compiler to read files on web?
- a LEX program to identify keywords and convert it into uppercase
- Identifier terminal except certain keywords
- Calling Scala compiler's AST from Java
- Computing the FOLLOW() set of a grammar
- JavaCC and Unicode issue. Why \u696d cannot be managed in JavaCC although it belong to the range "\u4e00"-"\u9fff"
- Three-address code and symbol tables
- Delegate caching behavior changes in Roslyn
- Get delimiter in Irony
- Compiler Errors including initializer before '<' token
Related Questions in GARBAGE-COLLECTION
- JVM is functioning very differently with same flags
- Why WeakReference to a WeakRef object is not garbage collected?
- GC cleaning the object before calling onPictureTaken method
- Know what objects got garbage collected
- Practical case JVM tunning to avoid full GC
- GC overhead limit exceed when reading large file
- Can java string literals be garbage collected?. If Yes, how to prove it?
- G1 doesn't process soft references
- why do I have to swapCursor(null) in onLoaderReset?
- Is it safe to assume static variables never get cleared?
- JVM ClassUnloadingWithConcurrentMark flag
- Java 8 Metaspace - Avoid decrease
- node.js memory usage issue
- G1GC Strange behavior
- Exposing whether an application is undergoing GC via UDP
Related Questions in CONTAINERS
- Positioning child at bottom of parent with scroll
- Where are docker images and containers stored when we use it with Windows?
- c++ container very efficient at adding elements to the end
- Set-like alternative for yaml files
- Julia: Enforce constraints on objects in a container?
- Control snapping on resize in C# scrollable container
- Creating a vertically draggable container in Adobe Flex 3.5
- How to set the read ACL on container in open stack swift such that allow Read for all users and deny for one user
- Which STL container(s)/algorithm(s) could I use to solve this?
- Persistent error coming from libusb0
- Make responsive text relative to responsive image?
- Initializing database in the base image of a running container
- Is there unique-value / set container in java-script
- Can we change width of container in css using Bootstrap3
- Use of container docker as a proxy for CF app to get public IP
Related Questions in GC-ROOTS
- Why does a non-static field not act as a GC root?
- Java garbage collection - finding set of root nodes
- How does garbage collector identify roots
- GC roots and local variables
- Is the stack garbage collected in Java?
- What is/are GC root objects referencing Java outer and inner classes?
- How are garbage collector (GC) roots stored?
- Finding roots for garbage collection in C
- Zookeeper: why instances of ClientCnxn are GC roots in MAT?
- How to find gc roots in a stack machine?
- GC roots in IBM java heapdump - is the list complete?
- JProfiler Heap Walker - select objects that are held by GC Root located in specific Java packages
- What are the roots?
- Thread as a GC root
- card table and write barriers in .net GC
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?
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)
A GC root is a location outside the heap that can contain a reference to an object inside the heap. A location can be anything that can store a reference. Usually it is four or eight bytes of memory storing 32 or 64 bit addresses but it can also be a machine register or space on disk. Sometimes a location is called a "slot" because you can "slot in" exactly one reference. A classical mark & sweep collector works by first marking all objects referenced by the roots and then continues the tracing from there.
Where and how roots are stored depends on the VM and gets very complicated when you consider things like partial GC, threading and JITting. But conceptually it's simple. Suppose you have a Python-like language with only functions and globals and the following code:
Assume GC happens on the indicated line. The callstack would look something like this:
The GC would scan through this callstack distinguishing between return addresses and references and marking the objects it finds. Then it would do the same for global references. They could be stored in a dictionary (hashmap) on the heap and referenced by a single root:
Note that the space required for storing all roots is tiny. You only need eight bytes (one reference) for the globals and eight bytes for each element on the callstack. You can run out of stack space and get a stack overflow but with say 256kb preallocated for the stack and proper tail call optimization it is a non-issue.