www.digitalmars.com         C & C++   DMDScript  

D - GC

reply imr1984 <imr1984_member pathlink.com> writes:
i have written an exe and a dll in D. Is it possible to make them share the same
garbage collector? The reason for this is that i want to share memory between
the exe and the dll freely without the hassle of creating copies of the data
etc. At the moment the garbage collector of the dll is overwriting the memory of
the exe.

Also, when is that section "How Garbage Collection Works" on the site gonna be
written?
Mar 30 2004
parent reply "Walter" <walter digitalmars.com> writes:
You'll have to put the gc into the dll as 'exported', and then create an
import library for the gc entry points to link the exe with.

"imr1984" <imr1984_member pathlink.com> wrote in message
news:c4bmh3$5qc$1 digitaldaemon.com...
 i have written an exe and a dll in D. Is it possible to make them share
the same
 garbage collector? The reason for this is that i want to share memory
between
 the exe and the dll freely without the hassle of creating copies of the
data
 etc. At the moment the garbage collector of the dll is overwriting the
memory of
 the exe.

 Also, when is that section "How Garbage Collection Works" on the site
gonna be
 written?
Mar 30 2004
parent reply imr1984 <imr1984_member pathlink.com> writes:
so do you mean i pass the _gc global variable to the dll, and then comment out
the gc_init() and gc_term() calls in the dll?

In article <c4ckhi$1neo$1 digitaldaemon.com>, Walter says...
You'll have to put the gc into the dll as 'exported', and then create an
import library for the gc entry points to link the exe with.

"imr1984" <imr1984_member pathlink.com> wrote in message
news:c4bmh3$5qc$1 digitaldaemon.com...
 i have written an exe and a dll in D. Is it possible to make them share
the same
 garbage collector? The reason for this is that i want to share memory
between
 the exe and the dll freely without the hassle of creating copies of the
data
 etc. At the moment the garbage collector of the dll is overwriting the
memory of
 the exe.

 Also, when is that section "How Garbage Collection Works" on the site
gonna be
 written?
Mar 31 2004
parent reply "Walter" <walter digitalmars.com> writes:
Are you familiar with the mechanics of making a DLL in C? dllexport,
dllimport, etc.?

"imr1984" <imr1984_member pathlink.com> wrote in message
news:c4eghk$1l6o$1 digitaldaemon.com...
 so do you mean i pass the _gc global variable to the dll, and then comment
out
 the gc_init() and gc_term() calls in the dll?

 In article <c4ckhi$1neo$1 digitaldaemon.com>, Walter says...
You'll have to put the gc into the dll as 'exported', and then create an
import library for the gc entry points to link the exe with.

"imr1984" <imr1984_member pathlink.com> wrote in message
news:c4bmh3$5qc$1 digitaldaemon.com...
 i have written an exe and a dll in D. Is it possible to make them share
the same
 garbage collector? The reason for this is that i want to share memory
between
 the exe and the dll freely without the hassle of creating copies of the
data
 etc. At the moment the garbage collector of the dll is overwriting the
memory of
 the exe.

 Also, when is that section "How Garbage Collection Works" on the site
gonna be
 written?
Mar 31 2004
parent reply imr1984 <imr1984_member pathlink.com> writes:
well i dont want to resort to an import library because i want the dll to be
like a plug-in for my exe, so i want to be able to swap around dlls and load
them dynamically using LoadLibrary() etc. Is there no way to pass the exes gc
variable safely to the dll? I tried it but it caused crashing

In article <c4frhb$nfv$1 digitaldaemon.com>, Walter says...
Are you familiar with the mechanics of making a DLL in C? dllexport,
dllimport, etc.?

"imr1984" <imr1984_member pathlink.com> wrote in message
news:c4eghk$1l6o$1 digitaldaemon.com...
 so do you mean i pass the _gc global variable to the dll, and then comment
out
 the gc_init() and gc_term() calls in the dll?

 In article <c4ckhi$1neo$1 digitaldaemon.com>, Walter says...
You'll have to put the gc into the dll as 'exported', and then create an
import library for the gc entry points to link the exe with.

"imr1984" <imr1984_member pathlink.com> wrote in message
news:c4bmh3$5qc$1 digitaldaemon.com...
 i have written an exe and a dll in D. Is it possible to make them share
the same
 garbage collector? The reason for this is that i want to share memory
between
 the exe and the dll freely without the hassle of creating copies of the
data
 etc. At the moment the garbage collector of the dll is overwriting the
memory of
 the exe.

 Also, when is that section "How Garbage Collection Works" on the site
gonna be
 written?
Apr 01 2004
parent reply Vathix <vathix dprogramming.com> writes:
imr1984 wrote:
 well i dont want to resort to an import library because i want the dll to be
 like a plug-in for my exe, so i want to be able to swap around dlls and load
 them dynamically using LoadLibrary() etc. Is there no way to pass the exes gc
 variable safely to the dll? I tried it but it caused crashing
Have one special DLL that the EXE and plugins link with that contains the GC. I've wanted to do this before but I'm not exactly sure what all to export. Plus I think the DLL would need a special shared memory section so each time it's loaded it shares the same GC state. -- Christopher E. Miller
Apr 01 2004
parent reply Hauke Duden <H.NS.Duden gmx.net> writes:
Vathix wrote:
 well i dont want to resort to an import library because i want the dll 
 to be
 like a plug-in for my exe, so i want to be able to swap around dlls 
 and load
 them dynamically using LoadLibrary() etc. Is there no way to pass the 
 exes gc
 variable safely to the dll? I tried it but it caused crashing
Have one special DLL that the EXE and plugins link with that contains the GC. I've wanted to do this before but I'm not exactly sure what all to export. Plus I think the DLL would need a special shared memory section so each time it's loaded it shares the same GC state.
On Windows every DLL is loaded at most once per process (multiple LoadLibrary calls will just return a new handle to the same module) and memory allocated by any module of the process can be accessed by all the other modules. So no explicit memory sharing stuff should be required. Hauke
Apr 01 2004
parent Vathix <vathix dprogramming.com> writes:
Hauke Duden wrote:

 Vathix wrote:
 
 well i dont want to resort to an import library because i want the 
 dll to be
 like a plug-in for my exe, so i want to be able to swap around dlls 
 and load
 them dynamically using LoadLibrary() etc. Is there no way to pass the 
 exes gc
 variable safely to the dll? I tried it but it caused crashing
Have one special DLL that the EXE and plugins link with that contains the GC. I've wanted to do this before but I'm not exactly sure what all to export. Plus I think the DLL would need a special shared memory section so each time it's loaded it shares the same GC state.
On Windows every DLL is loaded at most once per process (multiple LoadLibrary calls will just return a new handle to the same module) and memory allocated by any module of the process can be accessed by all the other modules. So no explicit memory sharing stuff should be required. Hauke
Oh yea! you're right. I was thinking about it being loaded by multiple processes, which that isn't the case here. -- Christopher E. Miller
Apr 01 2004