The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem with memory leak kshk123 HP-UX 2 05-25-2009 08:01 AM
memory leak? lenna IP Networking 2 05-25-2009 07:35 AM
Memory leak in pthread mindTeaser UNIX for Advanced & Expert Users 4 05-18-2009 02:30 AM
Memory leak of fork() whererush High Level Programming 7 05-11-2006 12:51 PM
about virtual memory and memory leak shriashishpatil High Level Programming 4 02-20-2006 11:31 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-30-2006
sonali sonali is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 7
memory leak problem

hi all

Can any one plz explain me about memory leak problem

Thankx
  #2 (permalink)  
Old 08-30-2006
Hitori's Avatar
Hitori Hitori is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2006
Posts: 360
This happens when you dynamically take memory from the heap (e.g. by calling malloc()) and forget to release it (free())
  #3 (permalink)  
Old 09-12-2006
nathanmca nathanmca is offline
Registered User
  
 

Join Date: Jun 2005
Location: Chennai
Posts: 3
try using rational purify to check the amount of memory leaked
  #4 (permalink)  
Old 10-11-2006
mellibra mellibra is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 1
Quote:
Originally Posted by nathanmca
try using rational purify to check the amount of memory leaked
What's the rational purify?
  #5 (permalink)  
Old 10-12-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,787
He is suggesting a tool for you to use to locate memory leaks in code. From your question, it sounds like you wanted to understand a memory leak, maybe not fix it.

Other tools: electric fence, valgrind
  #6 (permalink)  
Old 05-25-2009
ogerassimov ogerassimov is offline
Registered User
  
 

Join Date: May 2009
Posts: 4
Use Smart Pointers

Hello sonali

If this is a new development and if you are going to use multi-thread processes (pthread), and if they will live very long time, and if you are going to develop in C++.

Then I recommend you to use smart pointers and exceptions ( for error handling ) .

You could read about smart pointers at Boost C++ Libraries and also you can create such by yourselves. Pure C++ without any C influence. I've used such technique and the result is very nice. Programming is close to JAVA style. All resources allocated at constructor, deallocation at destructor. Check also what's written about C++ exception at the C++ standard.

There is other ways too. For example you can spawn new processes for each new "task", allocate and do not free anything, When the task is completed terminate the process, and OS will free everything.

Nevertheless which approach you gonna use to deal with "Memory/Resource Leaks"
Use valgrind to check what's up.

Best Regards
O.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:19 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0