authornari / minigc Goto Github PK
View Code? Open in Web Editor NEWminimum gc
Home Page: http://d.hatena.ne.jp/authorNari/
License: MIT License
minimum gc
Home Page: http://d.hatena.ne.jp/authorNari/
License: MIT License
typedef struct t{
int data;
struct t *next;
}T;
void main(){
T* obj1 = mini_gc_malloc(sizeof(T));
add_roots(obj1,(void*)obj1+sizeof(T));
T* obj2 = mini_gc_malloc(sizeof(T));
obj1->next = obj2;
//there is not call add_roots ,beacuse obj1 is reference obj2 by pointer next
//so let's call gc
garbage_collect()
}
expect: obj1 and obj2 can't be sweep
actual: obj1 be sweep, obj2 is just be mark
so i think problem is here:
void gc_mark_range(void *start,void *end){
for (p = start; p < end; p++) {
//over here, the obj1 havs no chance to mark
gc_mark(*(void **)p);
}
}
I am a little confused about mark part.
i know sweep part is recursive the gc_heaps to find unuse object. but not any reference about root_ranges
in your project
void add_roots(void * start, void * end){}
garbage_collect
function ,i find your recursive root_ranges
to mark all the objects,but i didn't find where the root_ranges
was usedvoid
garbage_collect(void)
{
size_t i;
//over there
// i didn't find anywhere to use the root_ranges and initialization
for (i = 0; i < root_ranges_used; i++) {
gc_mark_range(root_ranges[i].start, root_ranges[i].end);
}
}
can you give and example test to finish the entirly gc
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.