You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
static __thread Env env;
structEnv {
nongcmember nogc;
gcmember gc;
};
structgcmember {
void* operatornew(std::size_t sz) {
returnGC_MALLOC(sz);
}
};
voidmain(){
env.gc = newgcmember();
// doo stuff// after some time env.gc seems to get collected // and another object gets allocated at the position
}
I'm initializing the Env struct in my main method.
After some time I allocate the gcmember and store it in env.gc.
Then my application runs for quite some time and env.gc seems to get collected.
Now I have found one solution:
GC_add_roots(&env, &env + 1);
this works well, but I'd like to remove this root after the thread exited and the thread local variables are cleaned up.
So I looked at GC_CALL GC_remove_roots but in the docs it says:
"May be unimplemented on some platforms."
Hello,
my code looks like this:
I'm initializing the
Env
struct in my main method.After some time I allocate the
gcmember
and store it inenv.gc
.Then my application runs for quite some time and
env.gc
seems to get collected.Now I have found one solution:
this works well, but I'd like to remove this root after the thread exited and the thread local variables are cleaned up.
So I looked at
GC_CALL GC_remove_roots
but in the docs it says:"May be unimplemented on some platforms."
bdwgc/include/gc.h
Line 601 in 5937294
Is there an easier way to use thread locals as roots?
The text was updated successfully, but these errors were encountered: