By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,474 Members | 3,141 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,474 IT Pros & Developers. It's quick & easy.

[BUG?]Using inheritance case memory leak?

P: n/a
boy
Hi all,
I have created a simple template class as follow, but i encountered memory
leakage on the base.Render(writer). Have all you of encountered the same
problem?
using System;
using System.Web.UI;
public class PageBase : System.Web.UI.Page
{
private string _pageTitle;
public string PageTitle
{
get { return _pageTitle; }
set { _pageTitle = value; }
}

protected override void Render(HtmlTextWriter writer)
{
// First we will build up the html document,
// the head section and the body section.
writer.Write( @"
<html>
<head>
<title>" + PageTitle + @"</title>
</head>
<body>" );

// Then we allow the base class to render the
// controls contained in the ASPX file.
base.Render( writer );

// Finally we render the final tags to close
// the document.
Writer.Write( @"
</body>
</html>" );
}
}

Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Boy,
Just from looking at your code, I can't see how you are experiencing a
memory leak in that method. Omit that method and test again to see about
the memory usage. The memory problem is likely elsewhere.

Best regards,
Jeffrey Palermo

"boy" <bo*@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
Hi all,
I have created a simple template class as follow, but i encountered memory
leakage on the base.Render(writer). Have all you of encountered the same
problem?
using System;
using System.Web.UI;
public class PageBase : System.Web.UI.Page
{
private string _pageTitle;
public string PageTitle
{
get { return _pageTitle; }
set { _pageTitle = value; }
}

protected override void Render(HtmlTextWriter writer)
{
// First we will build up the html document,
// the head section and the body section.
writer.Write( @"
<html>
<head>
<title>" + PageTitle + @"</title>
</head>
<body>" );

// Then we allow the base class to render the
// controls contained in the ASPX file.
base.Render( writer );

// Finally we render the final tags to close
// the document.
Writer.Write( @"
</body>
</html>" );
}
}


Nov 18 '05 #2

P: n/a
boy
Hi Jeffrey,

Thank you for your reply.

I have used a software
(http://www.compuware.com/products/de...er/default.htm) to monitor
performance of my application.
The software found that there is memory leakge at that point. i.e. the line
"base.render(writer)".

I missed something in last post. The whole program should be as follows:
using System;
using System.Web.UI;
public class PageBase : System.Web.UI.Page
{
private string _pageTitle;
public string PageTitle
{
get { return _pageTitle; }
set { _pageTitle = value; }
}

}


public class ChildClass: PageBase{

protected override void Render(HtmlTextWriter writer)
{
// First we will build up the html document,
// the head section and the body section.
writer.Write( @"
<html>
<head>
<title>" + PageTitle + @"</title>
</head>
<body>" );

// Then we allow the base class to render the
// controls contained in the ASPX file.
base.Render( writer );

// Finally we render the final tags to close
// the document.
Writer.Write( @"
</body>
</html>" );
}

}

boy

"Jeffrey Palermo [MCP]" wrote:
Boy,
Just from looking at your code, I can't see how you are experiencing a
memory leak in that method. Omit that method and test again to see about
the memory usage. The memory problem is likely elsewhere.

Best regards,
Jeffrey Palermo

"boy" <bo*@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
Hi all,
I have created a simple template class as follow, but i encountered memory
leakage on the base.Render(writer). Have all you of encountered the same
problem?
using System;
using System.Web.UI;
public class PageBase : System.Web.UI.Page
{
private string _pageTitle;
public string PageTitle
{
get { return _pageTitle; }
set { _pageTitle = value; }
}

protected override void Render(HtmlTextWriter writer)
{
// First we will build up the html document,
// the head section and the body section.
writer.Write( @"
<html>
<head>
<title>" + PageTitle + @"</title>
</head>
<body>" );

// Then we allow the base class to render the
// controls contained in the ASPX file.
base.Render( writer );

// Finally we render the final tags to close
// the document.
Writer.Write( @"
</body>
</html>" );
}
}



Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.