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?
How are garbage collector (GC) roots stored?
615 Views Asked by xilpex At
1
There are 1 best solutions below
Related Questions in MEMORY
- 9 Digit Addresses in Hexadecimal System in MacOS
- Memory location changing from 0 to 1 consistently on Mac
- Would event listeners prevent garbage collecting objects referenced in outer function scopes?
- tensorrt inference problem: CPU memory leak
- How to estimate the memory size of a binary voxelized geometry?
- Java Memory UTF-16 Vs UTF-8
- Spring Boot application container memory footprint (Java 21)
- Low memory Windows CE
- How to throw an error when a program acesses a block of memory created by you that has been deallocated by a call of free?
- Golang bufio.Scanner: token too long
- Get the address and size of a loaded shared object on memory from C
- In Redis Databases how do we need to calculate the table size
- ClickHouse Materialized View consuming a lot of Memory and CPU
- How to reduce memory usage for large matrix calculations?
- How to use memray with Gunicorn or flask dev server?
Related Questions in COMPILER-CONSTRUCTION
- Reference: Crafting Interpreters. Print statement is not able to evaluate expression. Help me fix this (details below)
- Load function written in amd64 assembly into memory and call it
- I have implemented till Statements and State in Tree Walk Interpreter. I am pissed with an error
- Resolve shift/reduction conflict in grammar for expressions in PLY for calls to embedded functions
- Grammar for access to properties and calls to embedded functions
- LLVM code generation causes problems with pointer arithmetic
- what does react compiler mean actually?
- Errors on Recursive Descent Parsing Java
- Java CUP produces Shift-Reduce conflict when parsing a grammar for a C++ type language
- Three-Address-Code (TAC) and Conjunction/Disjunction
- How do I write an implicit cast for my strongly typed interpreter? (C++)
- Yacc parser not reducing specific production rules as intended
- Why is the function version tag consistently "Base" in HDF5 library?
- Sly parser, how are recursively defined types implemented?
- Does a non terminal token need an explicit definition?
Related Questions in GARBAGE-COLLECTION
- Java SoftReference: Soft references were not collected before the occurrence of OOM
- Would event listeners prevent garbage collecting objects referenced in outer function scopes?
- How to prevent R from slowing down in long analysis besides freeing up memory?
- change GC in quarkus jib build docker container
- What is 'MarkDependentCodeForDeoptimization()' used for in V8's Mark-Compact phase?
- Is my closure in an expressjs middlware causing a memory leak?
- Why do different delivery methods have different results when applying PHP's global keyword?
- Comment optimiser l'utilisation des resources mémoires (RAM) sur flutter?
- The way Elasticsearch deals with control heap memory when indexing documents
- Is it possible for a .net core app run 2 different GC modes at the same time?
- Why do we need the finalizer in the disposable pattern if it is not guaranteed that it will be called by the garbage collector?
- Out of memory in clojure - Nested reduce on Lazy Sequence
- Why does process memory grow in .Net, but managed heap size does not change?
- What is wrong with this Reflection.Emit for value conversion delegates?
- Python, How to stop tkinter variables from being garbage-collected?
Related Questions in CONTAINERS
- AttributeError: module 'numba' has no attribute 'generated_jit'
- Docker container does not find System Daemon of nordvpn after reboot
- How container isolation is being achieved for windows containers which use process isolation mode?
- Installing dotnet8 on amazonlinux 2023 image through dockerfile
- Mount Azure file share on Azure container app
- Spring Boot application container memory footprint (Java 21)
- Error initializing a docker container after installing transmission-daemon and nordvpn
- How to ping IPv6 address of link-local from container attached to bridge network
- C++ ordered map optimized with index access
- How to run a script after mysql container initialization?
- Azure Form Intelligence Connected Container performance
- Attaching a debugger to a container/instance running on a K8s Pod?
- Connecting Azure container app Spring boot backend to Azure container app Neo4j database
- Visual Studio 2022 free certificate problem. "cannot import key file " how to fix
- Open VS code from terminal in devcontainer?
Related Questions in GC-ROOTS
- How are garbage collector (GC) roots stored?
- What is/are GC root objects referencing Java outer and inner classes?
- Zookeeper: why instances of ClientCnxn are GC roots in MAT?
- JProfiler Heap Walker - select objects that are held by GC Root located in specific Java packages
- GC roots in IBM java heapdump - is the list complete?
- Why does a non-static field not act as a GC root?
- card table and write barriers in .net GC
- Thread as a GC root
- Java garbage collection - finding set of root nodes
- How to find gc roots in a stack machine?
- Finding roots for garbage collection in C
- How does garbage collector identify roots
- GC roots and local variables
- What are the roots?
- Is the stack garbage collected in Java?
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 # Hahtags
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?
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.