How can I force the shell to Release() all the IShellFolder items
before exiting the DLL?
CanUnloadDll() does not seem to be checked when the explorer window is
killed in this way. Causes hideous memory leaks.
TIA, Rich
Sent via Deja.com http://www.deja.com/
Before you buy.
Big Rich <bbm...@my-deja.com> a écrit dans le message :
819s75$q5q$1...@nnrp1.deja.com...
bye
juergen
------
Home: ds9.net/schmied
How would the shell use such pointers? It would have to restart the DLL
to use them. Does this sound possible? Can it use a new instance of a
DLL to execute class methods on an object that was created by a
different DLL instance? Would not the ShellFolder object be destroyed
by memory deallocation when it's app (ie. the DLL) was killed? If so
then the pointers could only lead to memory access violations.
Food for thought?
At process termination, all the memory allocated by the process
gets freed automatically, so the cleanup is implicit.
--
(My return address is intentionally invalid to foil spammers. Delete the
".---" to get my real address. I do this on my own time with my own money;
my responses are not to be considered official technical support or advice.
Personal requests for assistance will be ignored.)
No. Maybe it's a bug -surprising, yet- because undocumented and because
namespaces have been tried many times par developers since the release date
of Win95.
Or maybe it's by design (undocumented design, as usual...), or simply
something we missed.
Big Rich <bbm...@my-deja.com> a écrit dans le message :
81fcja$q43$1...@nnrp1.deja.com...
I humbly disagree...
The ShellFolder objects hold PIDLs which are created with IMalloc and
thus are not part of DLL's memory space. If the ShellFolders are
destroyed without a chance to clean up all references to these objects
are lost and hence they become memory leaks.
"At process termination" <- When a proces is terminated all the memory
allocated by all the Dll's is freed up.
If you have any cleanup needs over and above that, you will get a
D__PROCESS_DETECH message sent to your DllEntryPoint function, which you can
use to do any cleanup that shutting down a process does not do.
Chris
--
As in well beyond the lifetime of the process? If I write a well-behaved
COM object that exposes services to a client I expect that client to
treat my object with respect. Just because some idiot wrote some broken
code once, why does that mean I get my code shot down before it has had
a chance to tidy up behind itself?
In addition, I've observed that on Win95+IE4+shell update the process
gets terminated whilst the final Release of my final IShellFolder was
still running. This is simply appalling behaviour on the part of the
shell as a COM client.
>At process termination, all the memory allocated by the process
>gets freed automatically, so the cleanup is implicit.
Sigh. And what about file integrity? Cleanup isn't necessarily just
deallocating memory. I'm developing a shell extension that accesses a
shared database. I want to be terminated cleanly so that I can close the
database cleanly and guard against corruption. Of course I could code
this into DllMain reason DLL_PROCESS_DETACH. But I *really* shouldn't
have to.
Sean
--
/-Sean Legassick---------------------find the band at------------\
@ work: se...@demon.net http://fly.to/parallax *
@ home: seanle...@cyberjunkie.com *
\--------------"So beautiful to be...state of emergency" - Bjork-/
IShellFolders, by vurtue of being in-proc servers, by definition
do not outlive their process.
>Just because some idiot wrote some broken
>code once, why does that mean I get my code shot down before it has had
>a chance to tidy up behind itself?
Because that idiot who wrote broken code shipped first. Certain
idiots who write broken code are #1 on the software charts in
their area.
Backwards compatibility with idiots is one of the highest
priorities for any operating system. You can say "It's a bug in
the application" as many times as you like to the customer; the
customer won't believe you. And the company that produces the
application issues a press release saying that "Microsoft
intentionally added code to make our application crash."
(Nevermind that the application was accessing memory after
freeing it.)
But they *are* a part of the process's memory space, which is
automatically cleaned up when the process terminates.
Yep, sorry - I missed a smiley off that one. The *reference* does as it
never gets released.
>>Just because some idiot wrote some broken
>>code once, why does that mean I get my code shot down before it has had
>>a chance to tidy up behind itself?
>
>Because that idiot who wrote broken code shipped first. Certain
>idiots who write broken code are #1 on the software charts in
>their area.
Okay that's a fair point. There are certain developers whose code you,
for commercial reasons, must ensure doesn't get broken.
What I really object to is that my code, which obeys all the rules, did
get broken because of this "feature" of the shell. And it isn't
documented anywhere that this would happen.
Well, it's always possible for the process to be terminated
before doing all its cleanup. "End Task" for example doesn't
give you a chance to clean up.
Sigh. And of course we inform our users that if they "End Task" our
products then they deserve what they get in terms of file corruption.
Anyway, we could go round and round this forever. I've had my whinge;
the shells that do this are out there in the field; so I'm just going to
have to deal with it.
You have to be ready to handle the case where your host
application dies without going through full cleanup.