Solved

How to find what the current process is using GetCurrentProcess

Posted on 2011-02-26
5
788 Views
Last Modified: 2013-11-20
I am trying to do some debugging of a program which gives some users a RunTime 226 error in a CAD program which we sit our dll based program on.  I cannot replicate the error so I am trying to track if my system is losing memory somewhere.

I can get the current process memory usage  with GetProcessMemoryInfo(GetCurrentProcess, etc. but I need to make sure that GetCurrentProcess is my dll functions, I have established that it is not the CAD engine.  

How do I get the name of the process for which I am getting the memory values.
0
Comment
Question by:R_A_Martin
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:JohnCz
ID: 34987848
I do not quite understand the forst part of your post so I am not sure why you are trying to get memory information from other process. It also can be a registry problem.
Try cleaning registry and reinstalling program in question.

Answering the second part of your post:
Use EnumProcesses to get all processes IDs. For each ID call OpenProcess to get a handle and use this handle and call EnumProcessModules passing this handle and use GetModuleBaseName to retreive name.
Use module name to determine if this is a mosule you are trying to collect info anf use this process ID to call GetProcessMemoryInfo.
0
 

Author Comment

by:R_A_Martin
ID: 34988409
John

Thanks that pointed me in the right direction and it has confirmed that current process was the CAD engine.

I now have to work out why calling the function to send the data to the separate debug logging exe seems to increase the memory used by the system all the time.
0
 
LVL 5

Accepted Solution

by:
JohnCz earned 500 total points
ID: 34988638
Where this function is called from? What is called to send a date?
Without debugging session I am not able to answer this question.

The most common problem with growing memory used by a process, is to allocate memory on the heap and not release it when is not needed.
Another common problem is to allocate windows resources and not releasing them. For example repetitive calling GetDC without releasing it will cause memory problrms.
0
 

Author Comment

by:R_A_Martin
ID: 34990768
Thanks. I am going to investigate further why the workingSetSize is growing. I have a separate program which I send information to from functions in the dll, I think this is perhaps where the issue might be.
0
 

Author Closing Comment

by:R_A_Martin
ID: 35045260
Not the complete answer
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
C Language combined operators 28 101
if loop in java 3 114
Smart Camera scanning and reading information 3 86
sumHeights  challenge 17 61
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now