Results 1 to 9 of 9

Thread: Identify Memory Leak -- or -- Not

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    857

    Identify Memory Leak -- or -- Not

    I always wondered how one goes about identifying whether a memory leak is occurring within their App (Process).

    Following part of procedure used to get some process memory information. The question is "so what"? That is I (it) return a "snapshot" of memory as a value, but how do I interpret this to determine if there is a leak or not?

    Code:
        If (GetProcessMemoryInfo(ProcessHandle, tPMC, Len(tPMC)) <> 0) Then
          PageFaultCount = Format(tPMC.PageFaultCount, "#,###")
          WorkingSetSize = FormatNumber(CStr(tPMC.WorkingSetSize))
          PageFileUsage = FormatNumber(CStr(tPMC.PageFileUsage))
        End If

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

    Re: Identify Memory Leak -- or -- Not

    Can't answer your question directly, but GDI memory leaks can be tracked with Task Manager. See the 'Memory Leak FAQ' link in my signature below.

    I'd say GDI leaks are the most common type of leaks. But it is possible to have other types of leaks and maybe others will chime in on how to look for those?
    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}

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    857

    Re: Identify Memory Leak -- or -- Not

    LaVolpe:

    Excellent WriteUp. Thanks for making it available to all.

  4. #4
    Hyperactive Member
    Join Date
    Aug 2011
    Location
    Palm Coast, FL
    Posts
    416

    Re: Identify Memory Leak -- or -- Not

    I've been using a tool called C++ Memory Validator which has pointed out lots of memory issues, which I had no idea I had!

  5. #5
    Hyperactive Member
    Join Date
    Aug 2017
    Posts
    380

    Re: Identify Memory Leak -- or -- Not

    Wikipedia's Memory debugger article has a list of several other tools that you could try. In particular, DynamoRIO's Dr. Memory and Valgrind's Memcheck are both worth checking out.

  6. #6
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,094

    Re: Identify Memory Leak -- or -- Not

    How do you use Valgrind w/ VB6 projects?

    cheers,
    </wqw>

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    857

    Re: Identify Memory Leak -- or -- Not

    Thanks to all poster to date for their input.

  8. #8
    Hyperactive Member
    Join Date
    Aug 2017
    Posts
    380

    Re: Identify Memory Leak -- or -- Not

    Quote Originally Posted by wqweto View Post
    How do you use Valgrind w/ VB6 projects?
    Well, I haven't actually tried Valgrind out, but according to their About page:

    Quote Originally Posted by Valgrind
    • Valgrind works with programs written in any language. Because Valgrind works directly with program binaries, it works with programs written in any programming language, be they compiled, just-in-time compiled, or interpreted. The Valgrind tools are largely aimed at programs written in C and C++, because programs written in these languages tend to have the most bugs! But it can, for example, be used to debug and profile systems written in a mixture of languages. Valgrind has been used on programs written partly or entirely in C, C++, Java, Perl, Python, assembly code, Fortran, Ada, and many others.
    However, it appears I must have overlooked the fact that they did not actually directly support the Windows platform. Nevertheless, here's what they've got to say on this matter:

    Quote Originally Posted by Valgrind
    Porting Plans

    Windows is not under consideration because porting to it would require so many changes it would almost be a separate project. (However, Valgrind + Wine can be made to work with some effort.) Also, non-open-source OSes are difficult to deal with; being able to see the OS and associated (libc) source code makes things much easier. However, Valgrind is quite usable in conjunction with Wine, which means that it is possible to run Windows programs under Valgrind with some effort.
    So, there's a possibility VB6 EXEs could be made to work with Valgrind, but it looks like it'll require significant effort. In that case, that leaves Dr. Memory as the only one of the two still worth trying out.

    I did wanted to evaluate Dr. Memory, but I could never get either of the two v1.11.0 Windows packages (MSI installer and portable ZIP file) they have on GitHub to finish downloading. I attempted downloading them on 2 PCs already and also tried to use a download manager (I was denied because GitHub required a username & password) but they still failed. Guess I'll just have to make do with Windows Task Manager and/or Process Hacker.

  9. #9
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,401

    Re: Identify Memory Leak -- or -- Not

    Looks like you can use Valgrind on Windows with the Windows Subsystem for Linux (Beta) on Windows 10 version 1607 (Build 14393.187) or above. Note, I haven't tried this, but apparently it works with Windows executables through the subsystem.

    http://www.albertgao.xyz/2016/09/28/...nd-on-windows/

    Also note: Skip section 3. Try it first time. - that section demonstrates a failed attempt and some commenters reported that performing the steps in section 3 forced them to jump through hoops to get things working with the steps listed in section 4. How to deal with it?.

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