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. 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
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.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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...
|
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. ...
|
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...
| |
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...
|
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...
|
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....
|
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.
...
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
| |
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...
| |