Outlook stays in memory

Add-in Express™ Support Service
That's what is more important than anything else

Outlook stays in memory
How can I find out what is keeping it in memory? 
Fernando Madruga


Guest



I've since been trying to comment out portions of the source code and this is what I found:

RzTreeVw uses RzShellUtils which in turn uses RzShellIntf.

Even removing all the code in RzTreeVw (just leaving the uses clauses) would cause the lockup; after some more digging, I found that what happens is that the finalization code of RzShellIntf is entered but never leaves. There is just one instruction there:

_CoUninitialize;

I removed it and outlook does no longer stay loaded...

Is there any sort of interaction between this and your code? (I'll also ask on Raize's support whether that instruction does need to be in their code).
Posted 30 Nov, 2005 07:43:51 Top
Dmitry Kostochko


Add-in Express team


Posts: 2830
Joined: 2004-04-05
Hi Fernando,

Is there any sort of interaction between this and your code? (I'll also ask on Raize's support whether that instruction does need to be in their code).


I think there is no direct iteraction between our code and CoUninitialize.
But there may be an iteraction with Outlook code. BTW, the CoUninitialize function must be called once for each successful call of the CoInitialize or CoInitializeEx function. Can you look at the code and see if the CoInitialize or CoInitializeEx functions are called.


Posted 30 Nov, 2005 09:45:23 Top
Fernando Madruga


Guest



Don't know if this post is going to be repeated as my previous post (about 4 hours ago) doesn't show here!

Here it goes anyway.

I've come to the following conclusions:

1) RzTreeVw, even with ALL code except uses clauses commented out, still produces the same outlook lock up;
2) RzTreeVw uses RzShellUtils which, in turn, uses RzShellIntf;
3) RzShellIntf's finalization routine contains just this one line of code:
_CoUninitialize;
4) Commenting out that line, does stop the error from occuring, i.e., outlook closes properly.

I'll be asking Raize Component's support for the negative effects of removing this line, but in the meantime, I'd like to know if this line of code interferes with the code that Add-In Express generates for me...

Thanks,
Fernando Madruga
Posted 30 Nov, 2005 11:31:07 Top
Fernando Madruga


Guest



Oops... Should have refreshed the page! :)

There is this one line in that unit's initialization routine:

_CoInitialize( nil );

Thanks for the help,
Fernando Madruga
Posted 30 Nov, 2005 11:34:00 Top
Dmitry Kostochko


Add-in Express team


Posts: 2830
Joined: 2004-04-05
Hi Fernando,

Do you have a possibility to edit the RzShellIntf.pas unit? If yes, let's try to change it like this:


var
  NeedToUninitialize: boolean;

initialization
  NeedToUninitialize := Succeeded(CoInitialize(nil));

finalization
  if NeedToUninitialize then CoUninitialize;


I found a similar code in the ComObj.pas unit from Borland. This unit is in the uses clause by default and doesn't make Oulook freezing.

Posted 01 Dec, 2005 07:01:02 Top
Fernando Madruga


Guest



Thanks for the help but it didn't work. I logged the variable's value and it is "True". Do you know of an easy way to find out ALL units in use by a given program/project? I could search all the units in use by my DLL so far to check them for CoInitialize() calls. Or some tool to see the unit loading order on a given program? I might try placing some units after/before other units to sort the problem...

Thanks,
Fernando Madruga

Posted 01 Dec, 2005 16:31:38 Top
Dmitry Kostochko


Add-in Express team


Posts: 2830
Joined: 2004-04-05
Hi Fernando,

Unfortunately I don't know about such tool.
What reply did you get from the Raize support? Are they aware of this issue? What did they recommend you?

Posted 02 Dec, 2005 07:33:51 Top
Fernando Madruga


Guest



Hi.

Thanks anyway.

I've tried to use their support foruns before resorting to e-mailing them, as this is not an urgent problem now that I know what is causing it and how to temporarily turn it off, but they haven't answered so far. I'll try again next week, possibly by e-mail, to see what they say and I'll post the solution here, as soon as I have one...

Thanks,
Fernando Madruga
Posted 03 Dec, 2005 07:20:22 Top
Dmitry Kostochko


Add-in Express team


Posts: 2830
Joined: 2004-04-05
Hi Fernando,

Ok, we will wait for the solution. Really interesting situation...

Posted 05 Dec, 2005 07:56:44 Top
Fernando Madruga


Guest



Solution provided by Raize support:

Change the affected unit's (RzShellIntf) initialization/finalization code to this:


var
  _UninitializeRequired: Boolean;

initialization
  _UninitializeRequired := _CoInitialize( nil ) = S_OK;

finalization
  if _UninitializeRequired then
    _CoUninitialize;
end.


It does work and it's almost like your sugestion, the difference being that instead of testing for success the actual result code is tested ( = S_OK); in your sugestion, even though the code returned was not S_OK, it still returned true in Succeeded.

Thanks for the help,
Fernando Madruga
Posted 05 Dec, 2005 12:38:10 Top