473,486 Members | 2,394 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1378
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
18164
by: Karaoke Prince | last post by:
Hi There, I have an update statement to update a field of a table (~15,000,000 records). It took me around 3 hours to finish 2 weeks ago. After that no one touched the server and no...
1
2019
by: Marc | last post by:
I want to write a C#/ASP.NET application where a user can go to a web page, start running a job, close their browser, and then come back later and see the results. The purpose for this application is...
31
3283
by: Jamie Burns | last post by:
Hello, I am writing a client / server application. There is 1 server, and many clients. The server processes requests from each client, and typically creates and manipulates C++ objects on their...
67
4187
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. ...
44
12619
by: RB | last post by:
How to extract bytes from long, starting from the last byte? For example, I have a long number: 0x12345678 I need to represent it as the following bytes list: 0x78, 0x56, 0x34, 0x12 Thanks in...
18
5831
by: Urs Vogel | last post by:
Hi I wrote an application server (a remoting sinlgeton), where processes must be stopped in very rare cases, done thru a Thread.Abort(). Occasionally, and only after a Thread.Abort(), this...
18
2166
by: Larry Herbinaux | last post by:
I'm having issues with garbage collection with my long-standing service process. If you could review and point me in the right direction it would be of great help. If there are any helpful...
2
3497
by: Jim M | last post by:
I rarely deal with recordsets directly with code, since I usually use Access queries, so be patient with this question. I want to open a recordset with various default variables used by my program....
4
2839
by: commander_coder | last post by:
Hello, I write a lot of CGI scripts, in Python of course. Now I need to convert some to long-running processes. I'm having trouble finding resources about the best practices to do that. ...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7132
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7180
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7341
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4870
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
266
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.