Mark and sweep is an algorithm used for garbage collection. It is implemented in interpreters for languages such as Ruby, ActionScript, and JavaScript. Periodic mark-and-sweep garbage collection periodically traverses the list of all variables and marks any values referred to by out of scope variables for deletion.
Questions tagged [mark-and-sweep]
25 questions
1
vote
1 answer
can you turn off javascript garbage collector for a debugging mode?
when I'm debugging javascript I'm constantly running into situations where due to scope issues I'm not able to access variables that were suppose to be provided to me by closure.
I can traverse up a stack level to put myself in the correct scope for…

user2167582
- 5,986
- 13
- 64
- 121
1
vote
1 answer
Implementing a Mark Sweep Garbage collector in C
I have this problem in C where I have to implement a garbage collector. I'm stuck on the fact that I was given 4 functions to complete and not sure how they connect to one another. I'm not sure what to do. This is what I have so far:
void mygc() {
…

Alfred
- 11
- 2
1
vote
0 answers
DIY Script language garbage collection (mark & sweep)
I'm working on some simple script language and I need a help in understanding how garbage collector works. As far as I understand it, garbage collector has two things:
Object pool - contains all allocated objects, can be represented as simple…

Ruslan
- 313
- 1
- 3
- 16
0
votes
1 answer
How heap memory scan (or object graph traversal) works in garbage collector?
I recently started to study garbage collectors (GCs) used in languages like Java.
I am particularly interested in tracing (or mark-and-sweep) GCs like G1 (garbage-first).
I am confused with some details in an object-graph traversal performed to mark…

yonghae
- 51
- 5
0
votes
0 answers
Does Mark-and-sweep algorithm work only with references?
It's not entirely clear to me how Mark-and-sweep algorithm works.
MDN
This algorithm reduces the definition of "an object is no longer needed" to "an object is unreachable".
It turns out that this algorithm works only with references on objects…

Ivan
- 478
- 2
- 13
0
votes
0 answers
Do all modern browsers work according to Mark-and-sweep algorithm?
It's not entirely clear to me how garbage collector works for js.
Do all modern browsers work according to Mark-and-sweep algorithm (Chrome, Firefox ...)?
MDN
Internet Explorer 6 and 7 are known to have reference-counting garbage collector for DOM…

Ivan
- 478
- 2
- 13
0
votes
1 answer
How does GC stop newly created memory/objects from cleaning up during a GC Cycle (Java/C#)
Suppose we take a sample code as below
class Employee
{
int id;
String name;
}
Employee e = new Employee(1, "NewEmployee");
In the above code, I'm assuming the allocation of heap memory for Employee Object happens first and then its…

Kishore Bandi
- 5,537
- 2
- 31
- 52
0
votes
0 answers
In mark and sweep, in what case would the stack hold more pointers than allocated heap nodes?
I'm not sure how we would run into a case where we have more pointers than allocated heap nodes on the stack? I've tried to understand the mark and sweeping faces, that frees unreachable nodes, but when would we have more pointers than nodes?
-1
votes
1 answer
Do we can't use the variables from function just because of "JS rules"?
I think it's a little bit strange question. But I'll explain what I mean.
It turns out that Mark-and-sweep algorithm clears the object references in this example after going out from this function.
function f() {
let a = 'some text';
var…

Ivan
- 478
- 2
- 13
-2
votes
1 answer
Common data structures used in java Garbage Collection techniques
I have come across the following question multiple times:
What data structures are used in garbage collection?
I haven't found many resources about the data structures used in GC algorithms.
Edit: I understand that the question seems too broad…

Chandrani H
- 126
- 2
- 10