DLL unloading

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

DLL unloading

Geoffrey King
I am calling a dll and it works (more or less), but when i make a mistake
(yes it happens) the dll doesn't get unloaded -  thats bad because i am
modifying the dll at the same time.

I am using calling default to load it and close to reverse it. The process
however seems a little flakey.

Any suggestions ?

The test code looks like --
x := MyLibrary default.
[
 x myFunc.
] ensure: [
 x close.
 Transcript show: 'closed'; cr.
]


Reply | Threaded
Open this post in threaded view
|

Re: DLL unloading

Geoffrey King
Actually its closer to the point - I get "Invalid access to memory
location."
The Dll exports this
char* version() {
    return "0.2";
}

It always occurs  on the second execution of the code
> x := MyLibrary default.
> [
>  x versionStore.
> ] ensure: [
>  x close.
>  Transcript show: 'closed'; cr.
> ]
Any suggestions appreciated.


"Geoffrey King" <[hidden email]> wrote in message
news:3e572b6b$0$19978$[hidden email]...

> I am calling a dll and it works (more or less), but when i make a mistake
> (yes it happens) the dll doesn't get unloaded -  thats bad because i am
> modifying the dll at the same time.
>
> I am using calling default to load it and close to reverse it. The process
> however seems a little flakey.
>
> Any suggestions ?
>
> The test code looks like --
> x := MyLibrary default.
> [
>  x myFunc.
> ] ensure: [
>  x close.
>  Transcript show: 'closed'; cr.
> ]
>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: DLL unloading

Ian Bartholomew-18
Geoffrey,

Can't help a lot.  I do remember similar sounding problems in the past when
I was developing a dll and Dolphin code in tandem but I can't remember the
details.

Have you checked the value returned by the #close operation.  According to
the comment in ExternalLibrary>>close (which is worth a read if you haven't
already seen it) that might indicate where the problem lies.

Can you also post the code for the Dolphin MyLibrary>>versionStore method.
That could be a cause of "Invalid memory access" errors and might be worth
checking.

As I said though, I can't help a lot :-)

--
Ian


Reply | Threaded
Open this post in threaded view
|

Re: DLL unloading

Geoffrey King
Ian,
Some more clues....
 - #close returns true.
 - executing the test code below twice in succession works first time gives
memory error on second time.
 - MyLibrary>>versionStore
 <stdcall: lpstr version>
 ^self invalidCall

- test code
x := DataLibrary default.
[
 Transcript show: (x versionStore); cr.
] ensure: [
 Transcript show: 'close result : '; show: (x close) printString; cr.
].
x := nil.

"Ian Bartholomew" <[hidden email]> wrote in message
news:vYR5a.6674$Lq.509442@stones...
> Geoffrey,
>
> Can't help a lot.  I do remember similar sounding problems in the past
when
> I was developing a dll and Dolphin code in tandem but I can't remember the
> details.
>
> Have you checked the value returned by the #close operation.  According to
> the comment in ExternalLibrary>>close (which is worth a read if you
haven't

> already seen it) that might indicate where the problem lies.
>
> Can you also post the code for the Dolphin MyLibrary>>versionStore method.
> That could be a cause of "Invalid memory access" errors and might be worth
> checking.
>
> As I said though, I can't help a lot :-)
>
> --
> Ian
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: DLL unloading

Geoffrey King
Just noticed, if i resave the #storeVersion after each test it never errors.
So, i guess, it is forcing a recompilation and fixes up the memory.


Reply | Threaded
Open this post in threaded view
|

Re: DLL unloading

Ian Bartholomew-18
In reply to this post by Geoffrey King
Geoffrey,

Try making the #ensure block ...

[DataLibrary closeDefault]

... and see if it makes any difference.  That should completely get rid of
the default within Dolphin and allow Windows to unload the dll.  The next
access attempt should then start again from scratch.  You _may_ need to
leave a few seconds between attempt to allow for the cleanups (Dolphin and
Windows?) to complete.

If I had a straw I would be grapping it tightly though :-)

--
Ian