Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to find what the current process is using GetCurrentProcess

Posted on 2011-02-26
5
Medium Priority
?
831 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:Janusz Czopowik
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:
Janusz Czopowik earned 1500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month11 days, 2 hours left to enroll

885 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