473,725 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why memory leaks?

I have this test code:

{
String s("123");
OK(s.Len() == 3);
OK is a define to print __LINE__ and increment a test_count and a failure count

String is built using std::string as the memory namager for the string.

I have the following method:
This one produces no errors with purify.
size_t String::Len(voi d)
{
if (str.empty()) return 0;
return strlen(str.c_st r());
// return str.size();
}

size_t String::Len(voi d)
{
return str.size();
}

THe routine above produces the one above. The folowing is from purify:
Finished test ( 1 error, 0 leaked bytes)
Purify instrumented SunOS/32/test (pid 15865 at Thu May 26 07:32:17 2005)
UMR: Uninitialized memory read
This is occurring while in:
__big_float_tim es_power [libc.a]
__binary_to_dec imal_fraction [libc.a]
_unpacked_to_de cimal_two [libc.a]
__k_double_to_d ecimal [libc.a]
double_to_decim al [libc.a]
econvert [libc.a]
Reading 2 bytes from 0xffbedfda on the stack.
Address 0xffbedfda is 1086 bytes below frame pointer in function
__k_double_to_d ecimal.
Current file descriptors in use: 5
Memory leaked: 0 bytes (0%); potentially leaked: 0 bytes (0%)
Purify Heap Analysis (combining suppressed and unsuppressed blocks)
Blocks Bytes
Leaked 0 0
Potentially Leaked 1 8200
In-Use 0 0
----------------------------------------
Total Allocated 1 8200
Program exited with status code 0.
* Basic memory usage (including Purify overhead):
2566822 code
1947676 data/bss
16388 heap (peak use)
3040 stack
It appears that std::string::si ze is causing the error.

I use gcc 3.4.2 on a solaris 8 box.
purify.sol.2002 a.06.00
Since IBM bought Purify we don't see updates/new releases

___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/
Texas Instruments ASIC Circuit Design Methodology Group
Dallas, Texas, 214-480-4455, b-******@ti.com
Jul 23 '05 #1
4 1707
On Thu, 26 May 2005, Billy Patton wrote:
On Thu, 26 May 2005, Billy Patton wrote:
I have this test code:

{
String s("123");
OK(s.Len() == 3);
OK is a define to print __LINE__ and increment a test_count and a failure
count

String is built using std::string as the memory namager for the string.

I have the following method:
This one produces no errors with purify.
size_t String::Len(voi d)
{
if (str.empty()) return 0;
return strlen(str.c_st r());
// return str.size();
}

size_t String::Len(voi d)
{
return str.size();
}

THe routine above produces the one above. The folowing is from purify:
Finished test ( 1 error, 0 leaked bytes)
Purify instrumented SunOS/32/test (pid 15865 at Thu May 26 07:32:17
2005)
UMR: Uninitialized memory read
This is occurring while in:
__big_float_tim es_power [libc.a]
__binary_to_dec imal_fraction [libc.a]
_unpacked_to_de cimal_two [libc.a]
__k_double_to_d ecimal [libc.a]
double_to_decim al [libc.a]
econvert [libc.a]
Reading 2 bytes from 0xffbedfda on the stack.
Address 0xffbedfda is 1086 bytes below frame pointer in function
__k_double_to_d ecimal.
Current file descriptors in use: 5
Memory leaked: 0 bytes (0%); potentially leaked: 0 bytes (0%)
Purify Heap Analysis (combining suppressed and unsuppressed blocks)
Blocks Bytes
Leaked 0 0
Potentially Leaked 1 8200
In-Use 0 0
----------------------------------------
Total Allocated 1 8200
Program exited with status code 0.
* Basic memory usage (including Purify overhead):
2566822 code
1947676 data/bss
16388 heap (peak use)
3040 stack
It appears that std::string::si ze is causing the error.

I use gcc 3.4.2 on a solaris 8 box.
purify.sol.2002 a.06.00
Since IBM bought Purify we don't see updates/new releases

___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/ Texas Instruments ASIC Circuit Design Methodology Group
Dallas, Texas, 214-480-4455, b-******@ti.com


I tried this code on the Linux box with
PurifyPlus.2003 a.06.13/i386_linux2/bin/purify
and had no leaks?????
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
std::string s("abc");
size_t len = s.size();
cout << "len = " << len << "\n";
return 0;
}
___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/ Texas Instruments ASIC Circuit Design Methodology Group
Dallas, Texas, 214-480-4455, b-******@ti.com


Must have been the older oversion of Purify on solaris. Ran with the
PurifyPlus 2003 version on Linux and leak went away.

As that great poet/philosopher Alf one said "go figure" :)
___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/
Texas Instruments ASIC Circuit Design Methodology Group
Dallas, Texas, 214-480-4455, b-******@ti.com
Jul 23 '05 #2
On Thu, 26 May 2005, Billy Patton wrote:
I have this test code:

{
String s("123");
OK(s.Len() == 3);
OK is a define to print __LINE__ and increment a test_count and a failure
count

String is built using std::string as the memory namager for the string.

I have the following method:
This one produces no errors with purify.
size_t String::Len(voi d)
{
if (str.empty()) return 0;
return strlen(str.c_st r());
// return str.size();
}

size_t String::Len(voi d)
{
return str.size();
}

THe routine above produces the one above. The folowing is from purify:
Finished test ( 1 error, 0 leaked bytes)
Purify instrumented SunOS/32/test (pid 15865 at Thu May 26 07:32:17
2005)
UMR: Uninitialized memory read
This is occurring while in:
__big_float_tim es_power [libc.a]
__binary_to_dec imal_fraction [libc.a]
_unpacked_to_de cimal_two [libc.a]
__k_double_to_d ecimal [libc.a]
double_to_decim al [libc.a]
econvert [libc.a]
Reading 2 bytes from 0xffbedfda on the stack.
Address 0xffbedfda is 1086 bytes below frame pointer in function
__k_double_to_d ecimal.
Current file descriptors in use: 5
Memory leaked: 0 bytes (0%); potentially leaked: 0 bytes (0%)
Purify Heap Analysis (combining suppressed and unsuppressed blocks)
Blocks Bytes
Leaked 0 0
Potentially Leaked 1 8200
In-Use 0 0
----------------------------------------
Total Allocated 1 8200
Program exited with status code 0.
* Basic memory usage (including Purify overhead):
2566822 code
1947676 data/bss
16388 heap (peak use)
3040 stack
It appears that std::string::si ze is causing the error.

I use gcc 3.4.2 on a solaris 8 box.
purify.sol.2002 a.06.00
Since IBM bought Purify we don't see updates/new releases

___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/ Texas Instruments ASIC Circuit Design Methodology Group
Dallas, Texas, 214-480-4455, b-******@ti.com


I tried this code on the Linux box with
PurifyPlus.2003 a.06.13/i386_linux2/bin/purify
and had no leaks?????
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
std::string s("abc");
size_t len = s.size();
cout << "len = " << len << "\n";
return 0;
}
___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/
Texas Instruments ASIC Circuit Design Methodology Group
Dallas, Texas, 214-480-4455, b-******@ti.com
Jul 23 '05 #3
Billy Patton wrote:
On Thu, 26 May 2005, Billy Patton wrote:
On Thu, 26 May 2005, Billy Patton wrote:
I have this test code:
[...]


Do you think you could at least trim your *own* signatures when you reply
to yourself?

And, please, keep in mind that Purify is not topical here. Talk to their
Tech Support about any issues you have with that product. This is
a _language_ newsgroup, please limit your posts to _language_ topics.

V
Jul 23 '05 #4
Billy Patton wrote:
I have this test code:

{
String s("123");
OK(s.Len() == 3);

[snip]

It's fairly well known that STL classes and purify sometimes interact
badly and the latter can be confused by the former. In part this is
because STL objects may do nonobvious things with their memory,
ostensibly for optimization purposes, such as not freeing memory
promptly and reserving it for later allocations. You should look at the
purify website as I believe this is discussed there.
Jul 23 '05 #5

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

Similar topics

4
16688
by: Maurice | last post by:
Hi there, I'm experiencing big memory problems on my webserver. First on an old RedHat 7.2 system, now on an other fresh installed Suse 8.2 system: Linux version 2.4.20-4GB (root@Pentium.suse.de) (gcc version 3.3 20030226 (prerelease) (SuSE Linux)) #1 Wed Aug 6 18:26:21 UTC 2003 Apache 1.3.27-41 PHP 4.3.1-52 MySQL 3.23.55-20
0
1867
by: Steve Binney | last post by:
My code makes synchronous HttpWebRequest and HttpRebResponse calls. In VS 2003, I am getting memory leaks and event handle leaks. I am closing all streams and using "using"statements. I have used .Net memory profiler from Sci Tech to analyze the leaks and they are coming from inside HttpWebRequest and HttpRebResponse. When I run my code on VS2005, I do not get any leaks. Is this problem fixed in .Net 1.1 SP1? I may not be able to wait...
4
2349
by: Morten Aune Lyrstad | last post by:
Ok, now I'm officially confused. I have a large project going, which uses a win32 ui library I am developing myself. And I'm getting weird memory leaks. I don't know if I can explain what is going on, but I really need some help on this one. Ok, so I have this class defined (written by Randy Charles Morin, www.kbcafe.com) which detects memory leaks. It creates a memory check point in the constructor, and another in the destructor, and...
2
4955
by: Generic Usenet Account | last post by:
I have been using STL for a long time now, without any problems. Recently we generated a purification report on our software using Rational Purify, and we found some memory leaks. My colleague claims that some of the memory leaks are due to the fact that "STL is wrought with memory leaks". Of course I disagree. I think that there are no "inherent leaks" with STL, but if used improperly, leaks will occur. One common source of leak that...
8
3412
by: ranjeet.gupta | last post by:
Dear All Is the Root Cause of the Memory corruption is the Memory leak, ?? suppose If in the code there is Memory leak, Do this may lead to the Memory Corruption while executing the program ? In nut shell, what is/are the realtion/s between the Memory Leak and Memory Corruption. Juts Theoritical Assumtion below:
0
3904
by: Frank Lopez | last post by:
Does anyone know if Microsoft generated a whitepaper on this topic? Does anyone know what the solution is? (meaning, eliminate the leak problem -- I am seeing three memory leaks from dllmodul.cpp(102) similar to what is mentioned below)... I am calling MFC as part of unmanaged code used by the managed code. +--------
4
5722
by: ali.jan | last post by:
Hi, It is trivial to load an assembly in a new Application Domain. Is there any way of loading an assembly in a new process? I tried using the Process class like this: Process p = new Process() p.StartInfo.FileName = mStartupFile p.StartInfo.UseShellExecute = False
23
4557
by: James | last post by:
The following code will create memory leaks!!! using System; using System.Diagnostics; using System.Data; using System.Data.SqlClient; namespace MemoryLeak
3
5324
by: Jim Land | last post by:
Jack Slocum claims here http://www.jackslocum.com/yui/2006/10/02/3-easy-steps-to-avoid-javascript- memory-leaks/ that "almost every site you visit that uses JavaScript is leaking memory". Anybody know anything about this? Does *Javascript* leak memeory, or does the *browser* leak memory?
16
5095
by: graham.keellings | last post by:
hi, I'm looking for an open source memory pool. It's for use on an embedded system, if that makes any difference. Something with garbage collection/defragmentation would be nice. It should have the ability to allocate different size chunks of memory not just a single size. It should error check for double free, etc. And it should be usable by a mixture of C and C++ subsystems. If I get that, I'm happy. Thank you very much.
0
8749
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
9398
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
9250
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8079
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...
0
6006
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
4507
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
4776
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3216
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
3
2153
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.