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

CreateToolhelp32Snapshot() and ERROR_NOT_ENOUGH_MEMORY

100 views
Skip to first unread message

Pieter

unread,
Jul 3, 2003, 5:52:01 PM7/3/03
to
When I call CreateToolhelp32Snapshot(TH32CS_SNAPMODULE) it returns
INVALID_HANDLEVALUE, and GetLastError() returns ERROR_NOT_ENOUGH_MEMORY.

When this situation happens, I can launch the app again and sometimes the
error happens again, and sometimes it starts working. Once the call
succeedes, normally after a few retries) it will not fail again (during my
test session).

Any ideas how to prevent the call from failing, or why it happens?


David Lowndes

unread,
Jul 3, 2003, 7:23:24 PM7/3/03
to
>Any ideas how to prevent the call from failing, or why it happens?

Suspect a coding bug - an uninitialised variable perhaps?

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq

arkadyf

unread,
Jul 4, 2003, 3:52:47 AM7/4/03
to
If that first CreateToolhelp32Snapshot you need TH32CS_SNAPPROCESS and after
that TH32CS_SNAPMODULE
Arkady

"Pieter" <msn...@insanegenius.com> wrote in message
news:#ugKw1aQ...@TK2MSFTNGP12.phx.gbl...

Pieter

unread,
Jul 7, 2003, 10:46:40 PM7/7/03
to
I firts call:
CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
Then for each process:
CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessId);

The problem only happens SOMETIMES, not always.
I would specifically like to know what conditions would cause the
ERROR_NOT_ENOUGH_MEMORY error.


Pieter

"arkadyf" <ark...@hotmail.com> wrote in message
news:uj6MQjfQ...@TK2MSFTNGP12.phx.gbl...

Ivan Brugiolo [MSFT]

unread,
Jul 8, 2003, 1:23:26 AM7/8/03
to
The ToolHelp API are wrappers around
RtlQueryProcessDebugInformation and NtQuerySystemInformation.
There are quite a few codepath that can fail
for unability to create or map a 4 Megs section in a process,
or to commit memory to back the section,
plus some regular memory allocation failures.

Hard to say without seeing the machine in question
and the contition under which the program is run.

I would suspect those API are likely to fail if the target process is
out-of-commit,
of if you lack the debug privilege for non-owned processes.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Pieter" <msn...@insanegenius.com> wrote in message

news:e#81FtPR...@TK2MSFTNGP11.phx.gbl...

0 new messages