473,320 Members | 2,097 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,320 software developers and data experts.

Memory leak due to ostream in C++

Hi,

I am using the ostream in my C++ program by including the headerfile #include <strstream.h> in solaris 10.2

But it showing the following memory leaks in the following functions.

void*operator new(unsigned) [rtlib.o]
void*operator new[](unsigned) [rtlib.o]
int strstreambuf::overflow(int) [libiostream.so.1]
int streambuf::xsputn(const char*,int) [libiostream.so.1]
void unsafe_ostream::outstr(const char*,const char*) [libiostream.so.1]
unsafe_ostream&unsafe_ostream::operator<<(const char*)
ostream&ostream::operator<<(const char*)
If its possible to resolve these memory leaks in this version of solaris10.2.

Could you please help me to resolve this issue.

In addition to this,could any one tell what are all the possible cases for memory leaks in C++

Thanks & Regards,
Muthu.
Jul 7 '10 #1
5 4252
Banfa
9,065 Expert Mod 8TB
<strstream.h> is old and deprecated you should be using <ostream> or possibly <fstream> or <sstream> if you want a file or string stream object.

Where the memory leaks are being reported it is almost a certainty that they are caused by an error in your own code.

Beyond that it is hard to comment due to the lack of detail you have provided.
Jul 7 '10 #2
Thank you Banfa

Could you please tell how to delete or deallocate the following 2 questions:
Qn:1
ostrstream *sql_stream = new ostrstream;
Qn:2
ostrstream sql_stream
char *sql_buffer;
sql_buffer = sql_stream.str();

for the Qn.1
I use

delete sql_stream;
sql_stream = NULL;
to deallocate it

for the Qn.2

I use

delete[]sql_buffer

to deallocate it

But still its showing memory leak

Could you please analyse on this Banfa
Jul 7 '10 #3
@Banfa
Thank you for your reply Banfa..I will check and tell
Jul 7 '10 #4
Can anyone please tell how to delete or deallocate the sql_stream for the following 2 questions:
Qn:1
ostrstream *sql_stream = new ostrstream;
Qn:2
ostrstream sql_stream
char *sql_buffer;
sql_buffer = sql_stream.str();

for the Qn.1
I use

delete sql_stream;
sql_stream = NULL;
to deallocate it

for the Qn.2

I use

delete[]sql_buffer

to deallocate it

But still its showing memory leak
Jul 7 '10 #5
Banfa
9,065 Expert Mod 8TB
What you have done looks like it might be right, however as far as I can tell ostrstream is a deprecated class at best and I have no knowledge of it.

I suggest you start using classes from the STL such as string and ostringstream.
Jul 7 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Elbert Lev | last post by:
#When I'm running this script on my windows NT4.0 box, #every time dialog box is reopened there is memory growth 384K. #Bellow is the text I sent to Stephen Ferg (author of easygui) # I have...
3
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...
32
by: John | last post by:
Hi all: When I run my code, I find that the memory that the code uses keeps increasing. I have a PC with 2G RAM running Debian linux. The code consumes 1.5G memory by the time it finishes...
8
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 ? ...
17
by: José Joye | last post by:
Hi, I have implemented a Service that is responsible for getting messages from a MS MQ located on a remote machine. I'm getting memory leak from time to time (???). In some situation, it is...
4
by: Don Nell | last post by:
Hello Why is there a memory leak when this code is executed. for(;;) { ManagementScope scope = new ManagementScope(); scope.Options.Username="username"; scope.Options.Password="password";...
23
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
5
by: nithya4u | last post by:
I am working on a c++ module, where large amount of data needs to be written to a stream and str() method is been used to assign the value of this to the char*. This produces the intended result....
7
by: Ragnar Agustsson | last post by:
Hi all I have been wandering about the best way to sandbox memory leaks in 3rd party libraries when using them from the .Net framework. I have a 3rd party library, written in C++, that leaks a...
22
by: Peter | last post by:
I am using VS2008. I have a Windows Service application which creates Crystal Reports. This is a multi theaded application which can run several reports at one time. My problem - there is a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.