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
18
votes
0 answers
Mark-and-Sweep vs. Automatic Reference Counting
As we all know, the HotSpot JVM uses a concurrent Mark-and-Sweep Garbage Collector to release unused objects on the heap. This is useful in a sense that programmers don't have to take care of memory while making their programs, but comes with an…

Clashsoft
- 11,553
- 5
- 40
- 79
12
votes
1 answer
"abort preclean due to time" in Concurrent Mark & Sweep
I'm getting "abort preclean due to time" when running Concurrent Mark & Sweep in Java 6.
What does it mean? Is the GC really halting in the middle before it did any real work?

ripper234
- 222,824
- 274
- 634
- 905
6
votes
1 answer
(U) Ruby Extensions: rb_gc_mark() and instance variables
I'm writing a ruby extension that defines a class.
If I use Data_Wrap_Struct() to implement my callback for rb_define_alloc_func(), do I need to manually mark and free the instance variables? Or is that still handled for me?

rampion
- 87,131
- 49
- 199
- 315
6
votes
2 answers
When is it necessary to declare volatile VALUEs in Ruby C extensions?
I can't find much documentation on when it's appropriate to declare a VALUE as volatile in Ruby extensions to avoid premature garbage collection of in-use objects.
Here's what I've learned so far. Can anyone fill in the blanks?
When volatile does…

Translunar
- 3,739
- 33
- 55
5
votes
2 answers
Regarding mark-sweep ( lazy approach ) for garbage collection in C++?
I know reference counter technique but never heard of mark-sweep technique until today, when reading the book named "Concepts of programming language".
According to the book:
The original mark-sweep process of garbage collection operates as follow:…

roxrook
- 13,511
- 40
- 107
- 156
4
votes
2 answers
Why white/gray/black in GC?
I'm implementing mark-and-sweep garbage collection in a simple scripting language API I'm working on and have been reading about various implementations of garbage collection. API's such as Lua use mark-and-sweep with white, gray and black…

Nick Bedford
- 4,365
- 30
- 36
4
votes
5 answers
Sweep Line Algorithm - Implementation for 1D plane
The problem is simple, There is some given 1D lines on a plane.
We need to find the total size of space having at least one line.
Let me discuss this with an example image-
This may a case. Or
This may be a case or anything like this.
I know it is…

Abrar Jahin
- 13,970
- 24
- 112
- 161
3
votes
2 answers
Using finalize as exclusive lock
If I use stop-the-world GC and do some stuff in my finalize() method can I assume that all threads are suspended and I can do whatever I want and no thread will dare to compete for resources with me except the GC thread?

Nutel
- 2,244
- 2
- 27
- 50
3
votes
1 answer
How does V8 manage its heap?
I know when V8's Garbage Collection is working, it will trace from GC's root so that unreachable objects will be marked and then be swept. My question is how GC traverses traverse those objects? There must be a data structure to store all objects…

AllenLin
- 170
- 1
- 10
2
votes
0 answers
Why are Reference Counting GCs Stigmatised?
I once read somewhere about a common thought amongst idealistic yet 'lazy' programmers trying their hand at implementing programming languages. It was as follows:-
'I know, I'll do an easy-to-implement and quick-to-write reference counting GCer, and…

Louis
- 2,442
- 1
- 18
- 15
2
votes
1 answer
Stop-the-world garbage collection for AST-interpreted language: prevent application threads waiting for one
I’m developing an AST-interpreted scripting language in C++. The interpreter has a simple stop-the-world mark-and-sweep garbage collector which, whenever collection is triggered, sends a stop request to all the application threads and then waits for…

Lorenzo Notaro
- 89
- 8
2
votes
2 answers
What are the advantages and disadvantages of having mark bits together and separate for Garbage Collection
I was watching video Google IO 2008 - Dalvik Virtual Machine Internals to understand how Dalvik VM works and why those people has preferred Dalvik VM over JVM for android. I found that android uses separate memory for Garbage information about the…

Saurabh Jain
- 1,227
- 1
- 16
- 28
1
vote
1 answer
How to store references in a mark and sweep garbage collector?
I started writing my own scripting language over the most recent weekend for both the learning experience and for my resume when I graduate high school. So far things have gone great, I can parse variables with basic types (null, boolean, number,…

Cole Shepherd
- 53
- 3
1
vote
1 answer
Which modern browsers use Mark and Sweep Algorithm for Garbage Collection?
While going through garbage collection, I came across Reference Counting and Mark & Sweep GC Algorithms.
Some research on the web says that Reference Counting is a thing of the past and most of the browsers today have adapted Mark and Sweep. As per…

Green goblin
- 9,898
- 13
- 71
- 100
1
vote
1 answer
What is the result of mark and sweep in this code?
What is the result of mark and sweep in this code :
var user = "mina";
var user = null;
console.log(user);
If I implement mark and sweep, var user = "mina" is seeped to garbage because it is not accessible any more. Is that correct?
user10266074