473,758 Members | 2,401 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Memory leak when using Response.Write( )

Hi all.

I have a web app, in which I use frames. My main frameset consists of
three inner frames.

When some button is pressed in frame A, then content of frame B is
reloaded. I am using such code to achieve this:
string strRedirect;
strRedirect = "<script language='Javas cript'>";
strRedirect += "parent.body.lo cation.href='WF SearchResult.as px';";
strRedirect += "</script>";
Response.Write( strRedirect);

I noticed that there are memory leaks in my app. I used .NET Memory
Profiler to trace them and I discovered that usage of memory increases
when content of some frame is loaded - I had a breakpoint on PageLoad
method in all frames, but usage of memory increasead after
Response.Write code and before PageLoad of frame.

So I think that old content of frame is not released and that is the
cause of memory leak.

Does anybody know some method to prevent memory leaks in situation I
described? Maybe there is some way I can get to the old frame and
dispose it?

Thanks in advance,
Piotrek

Jul 1 '06 #1
14 2705
I don't really see how there could be a memory leak from the code that
you've shown. It uses some memory, but it should all be returned when a
garbage collection occurs.

You can reduce the number of strings created from three to one:

string strRedirect;
strRedirect = "<script language='Javas cript'>" +
"parent.body.lo cation.href='WF SearchResult.as px';" +
"</script>";
Response.Write( strRedirect);

This reduces the amount of memory the code uses. Not that it really
should make that much of a difference, though.

Piotrek wrote:
Hi all.

I have a web app, in which I use frames. My main frameset consists of
three inner frames.

When some button is pressed in frame A, then content of frame B is
reloaded. I am using such code to achieve this:
string strRedirect;
strRedirect = "<script language='Javas cript'>";
strRedirect += "parent.body.lo cation.href='WF SearchResult.as px';";
strRedirect += "</script>";
Response.Write( strRedirect);

I noticed that there are memory leaks in my app. I used .NET Memory
Profiler to trace them and I discovered that usage of memory increases
when content of some frame is loaded - I had a breakpoint on PageLoad
method in all frames, but usage of memory increasead after
Response.Write code and before PageLoad of frame.

So I think that old content of frame is not released and that is the
cause of memory leak.

Does anybody know some method to prevent memory leaks in situation I
described? Maybe there is some way I can get to the old frame and
dispose it?

Thanks in advance,
Piotrek

Jul 1 '06 #2
Piotrek,
I think your assumption that an ASP.NET application with frames, which are
strictly a client-side browser-handled construct, is fallacious. All the
ASP.NET page knows is that it is being reqeusted, it cares not whether it is
being loaded "into a frame" or not - it still does exactly the same work.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Piotrek" wrote:
Hi all.

I have a web app, in which I use frames. My main frameset consists of
three inner frames.

When some button is pressed in frame A, then content of frame B is
reloaded. I am using such code to achieve this:
string strRedirect;
strRedirect = "<script language='Javas cript'>";
strRedirect += "parent.body.lo cation.href='WF SearchResult.as px';";
strRedirect += "</script>";
Response.Write( strRedirect);

I noticed that there are memory leaks in my app. I used .NET Memory
Profiler to trace them and I discovered that usage of memory increases
when content of some frame is loaded - I had a breakpoint on PageLoad
method in all frames, but usage of memory increasead after
Response.Write code and before PageLoad of frame.

So I think that old content of frame is not released and that is the
cause of memory leak.

Does anybody know some method to prevent memory leaks in situation I
described? Maybe there is some way I can get to the old frame and
dispose it?

Thanks in advance,
Piotrek

Jul 1 '06 #3
"Göran Andersson" <gu***@guffa.co mwrote in message
news:%2******** **********@TK2M SFTNGP05.phx.gb l...
You can reduce the number of strings created from three to one:
Three strings...?
Jul 2 '06 #4
Mark Rae wrote:
"Göran Andersson" <gu***@guffa.co mwrote in message
news:%2******** **********@TK2M SFTNGP05.phx.gb l...
>You can reduce the number of strings created from three to one:

Three strings...?
Yes, three strings. The strings created in the code are:

"<script language='Javas cript'>"

and

"<script
language='Javas cript'>parent.b ody.location.hr ef='WFSearchRes ult.aspx';"

and

"<script
language='Javas cript'>parent.b ody.location.hr ef='WFSearchRes ult.aspx';</script>"
Actually, it's more accurate to say that the code uses five strings;
three are constant strings and two are created by the code. The code I
proposed uses only one string, and it's constant so the code doesn't
create any string at all.
Jul 2 '06 #5
Thanks for your answers.

So if it is not a problem with frames, then I have no idea, what it can
be.

What more I noticed is that there are datasets (datacolumns,
dataviews), which are not collected by GC. I store results of search in
Session as datasets, but after a while I set them to null, so they
should be collected.

One more thing I do not understand is why usage of memory increases
after executing the code I posted earlier and before PageLoad method is
called.

I know that it is hard for you to answer that questions, but maybe you
know something, which could help me?

Piotrek.

Jul 2 '06 #6
When you remove the reference to the dataset, it won't be collected
immediately. It will be collected when the garbage collector is run, and
that only happens when the memory is needed, or when the garbage
collector thinks that it's convenient to do a collection.

It's normal for the memory usage to increase while an application runs.
If your application uses and releases a lot of objects, you would
observe a sawtooth like curve where the memory usage increases to a
certain point until a garbage collection occurs and frees up a ot of
memory at once.

Piotrek wrote:
Thanks for your answers.

So if it is not a problem with frames, then I have no idea, what it can
be.

What more I noticed is that there are datasets (datacolumns,
dataviews), which are not collected by GC. I store results of search in
Session as datasets, but after a while I set them to null, so they
should be collected.

One more thing I do not understand is why usage of memory increases
after executing the code I posted earlier and before PageLoad method is
called.

I know that it is hard for you to answer that questions, but maybe you
know something, which could help me?

Piotrek.
Jul 2 '06 #7
But memory is not released even when I explicitely call GC.Collect()
method.

I know that there should be sawtooth like curve. And it is like that
but with one exception: numer of live object instances is continously
getting bigger e.g. when my app. starts then there is about 100 live
objects. During work with the app this number is getting bigger to
let's say 500 objects. Then memory collection is called, but after it
there is still about 150 objects (50 more than there should be) - .NET
Memory Profiler says that there is a lot of strings, many DataColumns
and few DataTables and DataSets, which are not collected.

As a result IIS has to be periodically reseted to free all allocated
memory (even 5 times a day).

Jul 2 '06 #8
"Göran Andersson" <gu***@guffa.co mwrote in message
news:Ov******** ******@TK2MSFTN GP02.phx.gbl...
Yes, three strings. The strings created in the code are:

"<script language='Javas cript'>"

and

"<script
language='Javas cript'>parent.b ody.location.hr ef='WFSearchRes ult.aspx';"

and

"<script
language='Javas cript'>parent.b ody.location.hr ef='WFSearchRes ult.aspx';</script>"
Er, are you sure...?
Actually, it's more accurate to say that the code uses five strings; three
are constant strings and two are created by the code. The code I proposed
uses only one string, and it's constant so the code doesn't create any
string at all.
Er, OK...
Jul 2 '06 #9
Mark Rae wrote:
"Göran Andersson" <gu***@guffa.co mwrote in message
news:Ov******** ******@TK2MSFTN GP02.phx.gbl...
>Yes, three strings. The strings created in the code are:

"<script language='Javas cript'>"

and

"<script
language='Java script'>parent. body.location.h ref='WFSearchRe sult.aspx';"

and

"<script
language='Java script'>parent. body.location.h ref='WFSearchRe sult.aspx';</script>"

Er, are you sure...?
Why wouldn't I be?
>Actually, it's more accurate to say that the code uses five strings; three
are constant strings and two are created by the code. The code I proposed
uses only one string, and it's constant so the code doesn't create any
string at all.

Er, OK...
Jul 2 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6344
by: eddie wang | last post by:
How to convert the following html to asp page using response.write? Thanks. <td align="right"><Font class=content4><%=ars.Fields("REVENUE")%></td> *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
3
4671
by: Jeremy Lemaire | last post by:
Hello, I am working on cross platform code that is displaying a huge memory leak when compiled on 11.00 HPUX using the aCC -AA flag. It is not leaking on NT, LINUX, Solaris, or HPUX without the -AA flag. In another news group I came across some interesting (ok scarey) information regarding memory leaks in the STL list<...> container. I have compiled and executed the following code and verified that this does in fact leak on my system.
3
2547
by: Giovanni Boschi | last post by:
We have found a memory leak when using a COM library with a C# application. The leak appears only if the C# application is compiled with the /optimize flag. It goes away when the C# application is compiled with the /debug flag. The COM library is coded to fire asynchronous events, which are handled by the C# application. It is in the firing and handling of these events that the leak occurs. Why does the optimized application leak while...
4
4212
by: Nevyn Twyll | last post by:
Is there any way I can use a code-behind event (like a btn_Click event) to write some javascript into the Response? I was thinking of using Response.Write() to write the following code into the response: window.open("mynextpage.aspx","_blank", "height=300, width=450, left=100, top=100, " + "location=no, menubar=no, resizable=no, " + "scrollbars=no, titlebar=no, toolbar=no", true);
3
5585
by: Coby Herd | last post by:
I cannot find any information on how to insert an image into a block of text and have the text wrap around the image. All if the text and graphics in the client's site are being pulled from the database using response.write. When I write straight HTML, it is easy to place an image into a block of text and align the image right or left, having the text wrap around the image. Can anybody offer any suggestions? Thanx
3
8844
by: Jer425 | last post by:
Hello all, I'm trying to post to another page from asp.net and direct the user there. I've looked through the group and found a lot of information. The following code may work well for what I'm doing. Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click ** Response.Write("<!-- Include File='Example.aspx' -->")
7
3310
by: Jim in Arizona | last post by:
I'm brand new at ajax. In fact, about 20 minutes ago was the first time I got it to work. The problem I'm having on another page did not work, however. I'm running into the following error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server...
0
9492
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9299
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10076
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8744
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7287
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6564
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5175
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5332
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3832
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 we have to send another system

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.