Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

memory leak ...

Status
Not open for further replies.

wxz44428

Programmer
Aug 10, 2001
3
US
My asp page is creating a com object,
using Server.CreateObject("progid")
and then call one of its method, at last set it to
nothing. like the follwing:
<%
if IsEmpty(Session(&quot;obj&quot;)) then
set obj = Server.CreateObject(&quot;progid&quot;)
Set Session(&quot;obj&quot;) = obj
else
set obj = Session(&quot;obj&quot;)
end if

obj.method(some parameters)

set obj = nothing
%>

The problem is, if I keep on refreshing the web
browser, I can see the server side mtx.exe memory
usage keep on going up, as shown by NT performance
monitor on mtx.exe's private bytes. However, if
I wrap the same code within a VB application, and
put the method call within a big loop, as shown
below, performance monitor shows a flat plateau,
the memory useage does not increas at all.

VB code:
set obj = CreaetObject(&quot;progid&quot;)
for i = 1 to 100
obj.method (parameters..)
next
set obj = nothing

I know I am not suppose to assign the object var to
a session variable, since my object is of &quot;Apartment&quot;
model. However, if I don't do that, whenever the user
refresh the browser, the object will be recreated, and
MTX is not releasing the old object right away, meaning
task manager will show even more memory accumulated.

My object's method does not throw any exceptions at
all.

I guess my question is, how come VB app shows no memory
accumulation, while mtx.exe does ? I learned from MSDN,
on components that throw exceptions, there are some
particular cases that memory leak will happen, but as said,
I am not throwing at all.

I am using NT4.0 SP5, IIS 4.0, VBScript 5.5, and my
object is written with VC++ 6.0 SP3.

Thanks in advance for your kind assistance.
 
Are you using MTS to manage your COM objects? If not than I would suggest this. Wushutwist
 
Thanks for the quick reply.

I am not sure Set Session(&quot;obj&quot;) = obj will cause
the problem. Using session object will cause mtx
to hold onto to it before it timesouts. But refreshing
the browser, mtx should still using the same session
resource, it should not accumlate memory. I tried to
not using session variable, and use page level
object instead, but then as I said, when
the browser get refreshed, the asp page will recreate
the object, and dose not seem to be able to release
the resource right away and this will make the memory accumlated even worse. Therefore, I used session var
to make sure the object got created only once.

I am not using MTS to manage the object. Just a dumb
question, what difference will this make ? IIS will
ask MTS to manage the com object anyway, isn't it ?
isn't that is the reason why mtx.exe shows up ?

Thanks.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top