472,145 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

For how long will an ASP.NET process hold resources?

Hello everyone,

I was believing that the life of ASP.NET objects will end as soon as the
origionating Page object transmitted the response stream and frees, even if
you haven't explicitly free the objects, but now I'm not quite sure.

It happened to me that I have a ASP.NET page that'll read images from
the server to generate another image. For quick hand I've used the code like
this in order to "save" one variable declaration. (The code resides in
another object the Page creates.)

g.DrawImage(new System.Drawing.Bitmap(ImgFilePath1), 0, 0, w1, h1);

And soon I found the w3wp.exe continuously locks any files opened this
way. Now I've changed the program to the following to get rid of the
problem.

pic1 = new System.Drawing.Bitmap(ImgFilePath1);
g.DrawImage(pic1, 0, 0, w1, h1);
pic1.Dispose();

Now I wonders if file handles will not be freed, will memory or other
system resources be hold - perhep until the global GC process finally
collects them?

Thanks for any inputs.

Regards,
Lau Lei Cheong

--
If you want to mail to me, please replace all instance of "e" to "a" in my
email address. Thank you.
Sorry for any inconvience caused, but there's many spam-mailers.
Nov 19 '05 #1
2 1334
In my experience when ever working with any kind of stream and using
any kind of COM object it is best to explicitly close or dispose of the
objects.

We observed behavior of a message queue that did not release resources
until dispose was called, this was caused by (if I remember correctly)
the .Net message queue holding onto COM resources

Nov 19 '05 #2
As a general rule, anything that implements IDisposable should ALWAYS be
disposed. In the case of file IO, it should be closed and disposed as
quickly as possible.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:uI**************@tk2msftngp13.phx.gbl...
Hello everyone,

I was believing that the life of ASP.NET objects will end as soon as
the origionating Page object transmitted the response stream and frees,
even if you haven't explicitly free the objects, but now I'm not quite
sure.

It happened to me that I have a ASP.NET page that'll read images from
the server to generate another image. For quick hand I've used the code
like this in order to "save" one variable declaration. (The code resides
in another object the Page creates.)

g.DrawImage(new System.Drawing.Bitmap(ImgFilePath1), 0, 0, w1, h1);

And soon I found the w3wp.exe continuously locks any files opened this
way. Now I've changed the program to the following to get rid of the
problem.

pic1 = new System.Drawing.Bitmap(ImgFilePath1);
g.DrawImage(pic1, 0, 0, w1, h1);
pic1.Dispose();

Now I wonders if file handles will not be freed, will memory or other
system resources be hold - perhep until the global GC process finally
collects them?

Thanks for any inputs.

Regards,
Lau Lei Cheong

--
If you want to mail to me, please replace all instance of "e" to "a" in my
email address. Thank you.
Sorry for any inconvience caused, but there's many spam-mailers.

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Karaoke Prince | last post: by
31 posts views Thread by Jamie Burns | last post: by
67 posts views Thread by Steven T. Hatton | last post: by
44 posts views Thread by RB | last post: by
18 posts views Thread by Urs Vogel | last post: by
18 posts views Thread by Larry Herbinaux | last post: by
4 posts views Thread by commander_coder | last post: by
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.