Welcome to the myhosting.com Forums.
-
leaks
Any general tips for reducing memory leaks when you're putting together a basic computer program?
-
A memory leak occurs when memory is allocated (for example using a malloc() function), and not released. Often the error is caused by allocating the memory then returning from a function before de-allocating it.
To avoid the problem requres two steps:
Obviously, be careful writing code so that whenever memory is allocated, its always deallocated properly.
Add code so that the amount of free memory is visible; that way you can detect memory leaks - although not necessarily who's doing it.
As a part of the second step, it may be useful to have your own versions of malloc(), realloc() and free() which keep track of which functions call them. That can make it easier to find out who "owns" the lost memory.
One nasty problem is the operating system leaking memory. This is much harder to detect, apart from the application gradually slowing down as the dynamic memory has to start using hard drive as memory.
Read more: Answers.com - What is a memory leak and how can you avoid it
Similar Threads
-
By WrigleyF in forum Virtual Server
Replies: 0
Last Post: 2011-01-19, 08:42 AM
-
By WrigleyF in forum News, Announcements, and Notices
Replies: 0
Last Post: 2010-08-06, 12:01 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
Version 4.1.7
Copyright ©2000 - 2013
All times are GMT -4. The time now is 06:25 AM.