使用Response.Write()时内存泄漏 [英] Memory leak when using Response.Write()
问题描述
大家好。
我有一个网络应用程序,我使用框架。我的主框架由
三个内框组成。
当在框架A中按下某个按钮时,框架B的内容为
重新加载。我正在使用这样的代码来实现这个目标:
string strRedirect;
strRedirect ="< script language =''Javascript''>" ;;
strRedirect + =" parent.body.location.href =''WFSearchResult.aspx'';" ;
strRedirect + ="< / script>" ;;
Response.Write(strRedirect);
I注意到我的应用程序中存在内存泄漏。我使用.NET内存
Profiler来跟踪它们,我发现在加载某些帧的内容时,内存的使用会增加
- 我在PageLoad上有一个断点>
方法在所有帧中,但使用内存后增加了
Response.Write代码和之前的PageLoad框架。
所以我认为框架的旧内容未发布,这是内存泄漏的原因。
有没有人知道一些方法来防止内存泄漏情况我
描述?也许有一些方法我可以到旧框架和
处理它?<br />
提前谢谢,
Piotrek
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=''Javascript''>";
strRedirect += "parent.body.location.href=''WFSearchResult.aspx'';" ;
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
推荐答案
我真的没有看到代码中存在内存泄漏的问题
你已经表明了它使用了一些内存,但是当发生
垃圾收集时它应该全部返回。
您可以将创建的字符串数量从三个减少到一个:
string strRedirect;
strRedirect ="< script language =''Javascript''>" +
" parent.body.location.href =''WFSearchResult.asp x'';" +
"< / script>" ;;
Response.Write(strRedirect);
这减少了金额代码使用的内存。不过它确实不会产生那么大的差别。
Piotrek写道:
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=''Javascript''>" +
"parent.body.location.href=''WFSearchResult.asp x'';" +
"</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:
大家好。
我有一个网络应用程序,我在其中使用框架。我的主框架由三个内框组成。
当在框架A中按下某个按钮时,框架B的内容将被重新加载。我正在使用此类代码来实现此目的:
string strRedirect;
strRedirect ="< script language =''Javascript''>" ;;
strRedirect + =" parent。 body.location.href = '' WFSearchResult.aspx '';" ;
strRedirect + ="< / script>" ;;
Response.Write(strRedirect);
我注意到我的应用程序中存在内存泄漏。我使用.NET Memory
Profiler来跟踪它们,我发现在加载某些帧的内容时内存的使用会增加 - 我在所有帧中都有一个关于PageLoad
方法的断点,但是使用在Response.Write代码和PageLoad框架之前的内存增加。
所以我认为框架的旧内容没有被释放,这是内存泄漏的原因。
在我描述的情况下,有没有人知道一些防止内存泄漏的方法?也许有一些方法我可以到达旧框架并处理它?<br />
提前致谢,
Piotrek
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=''Javascript''>";
strRedirect += "parent.body.location.href=''WFSearchResult.aspx'';" ;
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
Piotrek,
我认为你假设一个带有框架的ASP.NET应用程序,它严格地是客户端浏览器处理的构造,是
,是谬误。所有
ASP.NET页面都知道它正在被请求,它不关心它是否被加载到框架中。与否 - 它仍然完全相同的工作。
彼得
-
联合创始人,Eggheadcafe.com开发人员门户网站:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
" Piotrek"写道:
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:
大家好。
我有一个网络应用程序,我使用框架。我的主框架由
三个内框组成。
当在框架A中按下某个按钮时,框架B的内容为
重新加载。我正在使用这样的代码来实现这个目标:
string strRedirect;
strRedirect ="< script language =''Javascript''>" ;;
strRedirect + =" parent.body.location.href =''WFSearchResult.aspx'';" ;
strRedirect + ="< / script>" ;;
Response.Write(strRedirect);
I注意到我的应用程序中存在内存泄漏。我使用.NET内存
Profiler来跟踪它们,我发现在加载某些帧的内容时,内存的使用会增加
- 我在PageLoad上有一个断点>
方法在所有帧中,但使用内存后增加了
Response.Write代码和之前的PageLoad框架。
所以我认为框架的旧内容未发布,这是内存泄漏的原因。
有没有人知道一些方法来防止内存泄漏情况我
描述?也许有一些方法我可以到旧框架和
处理它?<br />
提前谢谢,
Piotrek
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=''Javascript''>";
strRedirect += "parent.body.location.href=''WFSearchResult.aspx'';" ;
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
" G?ran Andersson" < gu *** @ guffa.com写信息
新闻:%2 ****************** @ TK2MSFTNGP05.phx.gbl .. 。
"G?ran Andersson" <gu***@guffa.comwrote in message
news:%2******************@TK2MSFTNGP05.phx.gbl...
您可以将创建的字符串数量从三个减少到一个:
You can reduce the number of strings created from three to one:
三个字符串.. 。?
Three strings...?
这篇关于使用Response.Write()时内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!