Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

memory usage for a process

0 views
Skip to first unread message

Nisse

unread,
Dec 11, 2003, 5:18:07 PM12/11/03
to
Hello,

How can I get the memory usage for a process in Windows
CE? I've tried with CreateToolhelp32Snapshot and
enumerated heaps, but it's hard to tell whether the
number I get is correct. Is there a better way?

I've googled to find a task manager sample or similar
illustrating this, but no luck.

In addition to allocated memory
(CreateToolhelp32Snapshot) I assume I need to include
the .exe's size to get a good value (?) unless it's
executed in place.

Is there a way to programatically detect if a binary is
executed in place?

I hope someone can give some help.
Thanks in advance
Nisse

Michael J. Salamone [eMVP]

unread,
Dec 11, 2003, 8:26:51 PM12/11/03
to
If you want a desktop solution (i.e. a desktop UI that hooks up to your
target device and reports back info), then check our Entrek TOOLBOX product.
It has a ProcMan tool that lets you view/monitor virtual memory footprint,
heap usage, see what DLLs are loaded, monitor process/thread performance.
Lot's more, too. Plus there's another tool to help you find memory leaks,
heap corruption, and other runtime errors to boot. Free eval is available
from our website (below).

Using CreateToolhelp32Snapshot and then Heap32First, etc to walk a heap
helps you determine heap usage, but that's hardly the full story in terms of
memory usage. Memory that is virtual alloc'd (app and dll code, thread
stacks, heap usage, direct calls to VirtualAlloc, and even toolhelp
snapshots) is truly your application's memory usage. You can get that from
a single call to GlobalMemoryStatus().

You can use GetFileAttributes() to determine is an application or DLL file
is XIP. If it has FILE_ATTRIBUTE_ROMMODULE, it is. But you still count
it's footprint in the memory usage for that particular process.

--

Michael Salamone [eMVP]
Entrek Software, Inc.
www.entrek.com


"Nisse" <anon...@discussions.microsoft.com> wrote in message
news:03a701c3c034$a71cc9e0$a401...@phx.gbl...

Nisse

unread,
Dec 17, 2003, 4:51:49 PM12/17/03
to

Thanks. FILE_ATTRIBUTE_ROMMODULE was useful.

GlobalMemoryStatus gives me the system's memory. Is there
no way to get per process data? Similar to what the task
manager shows in Windows XP?

>.
>

Michael J. Salamone [eMVP]

unread,
Dec 17, 2003, 7:03:07 PM12/17/03
to
MEMORYSTATUS struct (returned from GlobalMemoryStatus) has these two fields:

dwTotalVirtual
Indicates the total number of bytes that can be described in the user mode
portion of the virtual address space of the calling process.
dwAvailVirtual
Indicates the number of bytes of unreserved and uncommitted memory in the
user mode portion of the virtual address space of the calling process.

What else do you want? You can do your own virtual memory walking using
VirtualQuery. It's what GlobalMemoryStatus does, though.

--

Michael Salamone [eMVP]
Entrek Software, Inc.
www.entrek.com


"Nisse" <anon...@discussions.microsoft.com> wrote in message

news:03b901c3c4e7$f95a73d0$a401...@phx.gbl...

0 new messages