Results 1 to 7 of 7

Thread: Classic VB - Memory Leak Prevention and Detection

Threaded View

  1. #1

    Thread Starter
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Classic VB - Memory Leak Prevention and Detection

    Overview

    Disclaimer. This tutorial focuses heavily on GDI. Many other APIs, OCXs, DLLs and other references you add to your project may also present opportunities for leaking. However, most of the leaks we experience are those we created via GDI and GDI+ API calls. Therefore, focus has been set on GDI.

    I have organized some of my thoughts and have tried to, as compactly as possible, provide many years of experience with finding leaks, into a short, step by step process. As with most potential problems, prevention is less painful than the cure. The first Section of this five-part document is a list of what I consider the best coding practices to preventing leaks in the first place. I think that if you have little experience tracking down leaks in your application, the following will help. There are other more complicated methods to help resolve leaks which include memory dumps and other more advanced techniques. I do not claim to be that smart, what I offer here is a commonsense, and somewhat easy and free, approach to dealing with the leaky situation.

    A leaky application is a sure way for your application to lose all credibility with the user. Even worse, you, as a coder, may lose hard-earned credibility. I personally take pride in providing “leak-free” code. However, we all make mistakes, and the information within this document can help you correct those mistakes - it has helped me more times than I can remember and continues to.

    DEFINITIONS

    API. Application Programming Interface (DLL)
    Clean Up. Code used to destroy created objects, freeing memory back to the system
    DC. Device Context
    GDI. Graphics Device Interface (DLL)
    IDE. Visual Basic's Integrated Development Environment.
    Leak. Used or reserved memory that has not been freed and not returned to the system.

    SECTIONS:


    Here is an RTF file you can download to take with you. This FAQ was created with its information.
    Attached Files Attached Files
    Last edited by LaVolpe; Oct 21st, 2008 at 09:43 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width