Announcement Announcement Module
Collapse Forum Guidelines

Welcome to the Forums! The purpose of this forum is to allow you to discuss topics relating to hosting and topics of interest with other Customers. The primary focus should relate to issues not generally included in our Wiki or Control Panel, or information not provided by our Customer Support Team. Some examples include programming and coding support, web site design ideas and SEO practices.

The forum is not meant as a replacement to our Wiki or Customer Support. We highly recommend searching our Wiki before posting on the forum. Also, if you have a question for our Customer Support team, please contact them as you would normally.

We ask that if you have any complaints or questions relating specifically to your account, that you address them to our Customer Support department. Do not post personal account information such as passwords or other sensitive and private information the forum, as this type of information is best kept secret. Also, please be respectful of other users and refrain from defamatory comments or use of coarse language.

We will visit the forum from time to time, and contribute to various topics. We reserve the right to delete any posts which are deemed offensive or against the spirit of the forum. Any spamming or illegal activity will not be tolerated. We also reserve the right to block any user who violates these guidelines.

To get started, we welcome you to sign up at our User Management site. Any account created there will have access to these forums, our Wiki, our Ideas site and commenting permission on our Status Blog.
See more
See less
leaks Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • leaks

    Any general tips for reducing memory leaks when you're putting together a basic computer program?

  • #2
    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: - What is a memory leak and how can you avoid it