digitalmars.D.learn - Less known std.gc
- bearophile (11/11) Nov 19 2007 The std.gc module of Phobos contains various things that I don't underta...
- Lutger (10/24) Nov 19 2007 Hi, some of these functions are documented in Tango's GC, which are
- Christopher Wright (5/19) Nov 19 2007 There's nothing in any of that that allows you to allocate memory and
- Jarrett Billingsley (7/11) Nov 19 2007 Oh yes there is :) std.gc.alloc, std.gc.realloc, and std.gc.extend all
- Christopher Wright (6/19) Nov 19 2007 My mistake; thank you. That's why I didn't see a 'free' entry in std.gc.
- Jarrett Billingsley (5/10) Nov 19 2007 Oddly, there is a "setFinalizer" function in the internal GC implementat...
The std.gc module of Phobos contains various things that I don't undertand: void addRoot(void* p); void removeRoot(void* p); void addRange(void* pbot, void* ptop); void removeRange(void* pbot); void setTypeInfo(TypeInfo ti, void* p); void* getGCHandle(); void setGCHandle(void* p); Maybe you can point me to some more info about their usage and usefulness, or some code that uses them. (I think the docs of Phobos can gain some usage examples of those functions). Bye and thank you, bearophile
Nov 19 2007
bearophile wrote:The std.gc module of Phobos contains various things that I don't undertand: void addRoot(void* p); void removeRoot(void* p); void addRange(void* pbot, void* ptop); void removeRange(void* pbot); void setTypeInfo(TypeInfo ti, void* p); void* getGCHandle(); void setGCHandle(void* p); Maybe you can point me to some more info about their usage and usefulness, or some code that uses them. (I think the docs of Phobos can gain some usage examples of those functions). Bye and thank you, bearophileHi, some of these functions are documented in Tango's GC, which are probably identical: http://www.dsource.org/projects/tango/docs/current/tango.core.Memory.html There is also an example of overriding new for classes that contain some of these functions: http://www.digitalmars.com/d/memory.html#newdelete These links are about the first four functions only. These are useful to let the GC know whether some parts of memory should be scanned or not. I don't know about the other functions.
Nov 19 2007
bearophile wrote:The std.gc module of Phobos contains various things that I don't undertand: void addRoot(void* p); void removeRoot(void* p); void addRange(void* pbot, void* ptop); void removeRange(void* pbot); void setTypeInfo(TypeInfo ti, void* p); void* getGCHandle(); void setGCHandle(void* p); Maybe you can point me to some more info about their usage and usefulness, or some code that uses them. (I think the docs of Phobos can gain some usage examples of those functions). Bye and thank you, bearophileThere's nothing in any of that that allows you to allocate memory and then say, "Let the garbage collector handle this from now on." I guess I have to start writing code to delete the objects that I malloc'd; I have an embarrassing amount of memory leaks now.
Nov 19 2007
"Christopher Wright" <dhasenan gmail.com> wrote in message news:fhs891$277v$1 digitalmars.com...There's nothing in any of that that allows you to allocate memory and then say, "Let the garbage collector handle this from now on." I guess I have to start writing code to delete the objects that I malloc'd; I have an embarrassing amount of memory leaks now.Oh yes there is :) std.gc.alloc, std.gc.realloc, and std.gc.extend all allow you to allocate arbitrary blocks of GC'ed memory. Also if you allocate memory with alloc (and possibly realloc?) you can flag the block as containing or not containing pointers using std.gc.hasPointers(ptr) and std.gc.hasNoPointers(ptr).
Nov 19 2007
Jarrett Billingsley wrote:"Christopher Wright" <dhasenan gmail.com> wrote in message news:fhs891$277v$1 digitalmars.com...My mistake; thank you. That's why I didn't see a 'free' entry in std.gc. Is there any way to hook up a destructor, besides allocating memory with a constructor? I ask purely out of academic interest; I allocate objects manually in some cases, but I don't need to use destructors with them, currently.There's nothing in any of that that allows you to allocate memory and then say, "Let the garbage collector handle this from now on." I guess I have to start writing code to delete the objects that I malloc'd; I have an embarrassing amount of memory leaks now.Oh yes there is :) std.gc.alloc, std.gc.realloc, and std.gc.extend all allow you to allocate arbitrary blocks of GC'ed memory. Also if you allocate memory with alloc (and possibly realloc?) you can flag the block as containing or not containing pointers using std.gc.hasPointers(ptr) and std.gc.hasNoPointers(ptr).
Nov 19 2007
"Christopher Wright" <dhasenan gmail.com> wrote in message news:fhsko3$2or4$2 digitalmars.com...My mistake; thank you. That's why I didn't see a 'free' entry in std.gc. Is there any way to hook up a destructor, besides allocating memory with a constructor? I ask purely out of academic interest; I allocate objects manually in some cases, but I don't need to use destructors with them, currently.Oddly, there is a "setFinalizer" function in the internal GC implementation, but for some reason there is no public function in std.gc that corresponds to it. Maybe it's experimental?
Nov 19 2007