digitalmars.D.learn - What if gc.disable at all
- Sam Hu (6/6) Sep 23 2009 Greeting to everybody,
- Jarrett Billingsley (8/14) Sep 23 2009 You can do it. You have to avoid some features - setting array length,
- Sam Hu (3/3) Sep 23 2009 Thank you all for your help!
- BCS (6/17) Sep 23 2009 There are some parts of D (like AA) that allocate memory from the GC but...
- Tom S (11/27) Sep 24 2009 As for AAs, you should be able to replace them with Tango's
- Sam Hu (7/20) Sep 24 2009 Ah yes,I once translated most of Tango's tango.util.container.* into D2 ...
- Daniel Keep (6/14) Sep 24 2009 How about by reading the error message?
- Sam Hu (4/13) Sep 25 2009 Thanks a lot.But may I ask...so I have to use Tango's runtime in D2 othe...
Greeting to everybody, If this is too silly a question,please just ignore it. I was wondering what if GC is turned off during the lifetime of the application?Just as if D is a better,safer/unsafer C with class?Can't work?Or some special stuff need to handle? Thanks for your help in advance. Regards, Sam
Sep 23 2009
On Wed, Sep 23, 2009 at 8:14 AM, Sam Hu <samhudotsamhu gmail.com> wrote:Greeting to everybody, If this is too silly a question,please just ignore it. I was wondering what if GC is turned off during the lifetime of the application?Just as if D is a better,safer/unsafer C with class?Can't work?Or some special stuff need to handle? Thanks for your help in advance. Regards, SamYou can do it. You have to avoid some features - setting array length, concatenating/appending arrays, using associative arrays in any way - but other than that it works fine. One thing you'll notice though is that D1 makes it very difficult to do any kind of automated manual memory management. D2 at least gives you struct destructors and postblits, which makes writing something like a C++ smart_ptr within reach.
Sep 23 2009
Hello Sam,Greeting to everybody, If this is too silly a question,please just ignore it. I was wondering what if GC is turned off during the lifetime of the application?Just as if D is a better,safer/unsafer C with class?Can't work?Or some special stuff need to handle?There are some parts of D (like AA) that allocate memory from the GC but for which it would be hard to impossible for the programmer to tell when to deallocate. If you use these features while the GC is off, you will leak memory untill you turn it back on (at that point the GC will clean it up). In some short lived programs this is no problem.Thanks for your help in advance. Regards, Sam
Sep 23 2009
BCS wrote:Hello Sam,As for AAs, you should be able to replace them with Tango's tango.util.container.HashMap with the tango.util.container.Container.Container.Malloc (or .Chunk) allocator. It might be tricky to find memory leaks due to accidental GC usage, but you could e.g. hook the GC methods ( http://dsource.org/projects/kong ) (or modify the GC) and print stack traces in them. -- Tomasz Stachowiak http://h3.team0xf.com/ h3/h3r3tic on #D freenodeGreeting to everybody, If this is too silly a question,please just ignore it. I was wondering what if GC is turned off during the lifetime of the application?Just as if D is a better,safer/unsafer C with class?Can't work?Or some special stuff need to handle?There are some parts of D (like AA) that allocate memory from the GC but for which it would be hard to impossible for the programmer to tell when to deallocate. If you use these features while the GC is off, you will leak memory untill you turn it back on (at that point the GC will clean it up). In some short lived programs this is no problem.
Sep 24 2009
Tom S Wrote:As for AAs, you should be able to replace them with Tango's tango.util.container.HashMap with the tango.util.container.Container.Container.Malloc (or .Chunk) allocator. It might be tricky to find memory leaks due to accidental GC usage, but you could e.g. hook the GC methods ( http://dsource.org/projects/kong ) (or modify the GC) and print stack traces in them. -- Tomasz Stachowiak http://h3.team0xf.com/ h3/h3r3tic on #D freenodeAh yes,I once translated most of Tango's tango.util.container.* into D2 excluding one or two modules which heavily depends on Tango other modules.It get compiled.However,the test program crashed with below error message: Error 42:Symbol Undefined _D5tango4core6Memory2GC6addrOfFpvZPv ---errorlevel 1 I have no clue what this means and where to restart. Regards, Sam
Sep 24 2009
Sam Hu wrote:Ah yes,I once translated most of Tango's tango.util.container.* into D2 excluding one or two modules which heavily depends on Tango other modules.It get compiled.However,the test program crashed with below error message: Error 42:Symbol Undefined _D5tango4core6Memory2GC6addrOfFpvZPv ---errorlevel 1 I have no clue what this means and where to restart. Regards, SamHow about by reading the error message? Error 42:Symbol Undefined _D5tango4core6Memory2GC6addrOfFpvZPv --> Error 42:Symbol Undefined void* tango.core.Memory.GC.addrOf(void*) Ergo, you didn't link in tango.core.Memory, which it wants.
Sep 24 2009
Daniel Keep Wrote:How about by reading the error message? Error 42:Symbol Undefined _D5tango4core6Memory2GC6addrOfFpvZPv --> Error 42:Symbol Undefined void* tango.core.Memory.GC.addrOf(void*) Ergo, you didn't link in tango.core.Memory, which it wants.Thanks a lot.But may I ask...so I have to use Tango's runtime in D2 other than D2's runtime,or,to use both? Regards, Sam
Sep 25 2009