Solved

How to find what the current process is using GetCurrentProcess

Posted on 2011-02-26
5
814 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.

734 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