473,396 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

[BUG?]Using inheritance case memory leak?

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

Similar topics

6
by: Scott Niu | last post by:
Hi, I have this following simple c++ program, it will produce memory leak ( see what I did below ). My observation also showed that: There will be a mem leak when all the 3 conditions are true:...
19
by: Kamilche | last post by:
I have looked at many object-oriented programming frameworks out there for C. Though the ideas presented are intriguing, and I've used some of them in my own work, they all suffered some drawback...
16
by: Cybertof | last post by:
Hi ! I'm wondering about the use of the 'using' statement. In a procedure, should i declare all instance variables in a using clause ? In the below code, what would happen if MyFont & MyFont2...
3
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...
4
by: Gunasekaran Balakrishnan | last post by:
Hi, I am seeing a different sorting behaviour for varchar columns in Postgres 7.4.2. postgres 7.4.2 is ignoring case for varchar columns for "ORDER BY" commands where as 7.2.2 is not. I am...
4
by: Sebastian Böck | last post by:
Hello all, i have a view defined as a simple select of a table. This table is inherited by a couple of others. All entries belong to the child-tables. I also have an unconditional update rule...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 378 open ( +3) / 3298 closed (+34) / 3676 total (+37) Bugs : 886 open (-24) / 5926 closed (+75) / 6812 total (+51) RFE : 224 open...
7
by: Louis B. (ldb) | last post by:
I have a long running program that eventually crashes when valloc() returns a 0. This program is relatively non-trivial as it's written in Ada, is multithreaded, has alot of SSE routines. A memory...
71
by: desktop | last post by:
I have read in Bjarne Stroustrup that using malloc and free should be avoided in C++ because they deal with uninitialized memory and one should instead use new and delete. But why is that a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.