locked
CreateToolhelp32Snapshot "out of memory" question RRS feed

  • Question

  • I understand that CreateToolhelp32Snapshot might fail if there is not enough memory on the system on which it is being called. You used to be able to use TH32CS_SNAPNOHEAPS the flag to compensate for this but this no longer seems to be available. Any ideas what I can do to try to prevent this problem?
    Tuesday, January 9, 2018 11:31 AM

Answers

  • TH32CS_SNAPNOHEAP was for Win CE.

    I don't remember having got ERROR_NOT_ENOUGH_MEMORY on OS like XP...

    To list processes, you can also use other APIs like WTSEnumerateProcesses

    • Marked as answer by cb12__ Thursday, January 11, 2018 8:22 AM
    Tuesday, January 9, 2018 12:54 PM

All replies

  • TH32CS_SNAPNOHEAP was for Win CE.

    I don't remember having got ERROR_NOT_ENOUGH_MEMORY on OS like XP...

    To list processes, you can also use other APIs like WTSEnumerateProcesses

    • Marked as answer by cb12__ Thursday, January 11, 2018 8:22 AM
    Tuesday, January 9, 2018 12:54 PM
  • Ok, thanks for replying. That would explain why it is not available.
    Tuesday, January 9, 2018 7:33 PM
  • If your question has answered, please mark the appropriate response to close the thread.
    Wednesday, January 10, 2018 1:23 AM
  • Hi cb12_,

    thanks for posting here.

    >>I understand that CreateToolhelp32Snapshot might fail if there is not enough memory on the system on which it is being called. You used to be able to use TH32CS_SNAPNOHEAPS the flag to compensate for this but this no longer seems to be available. Any ideas what I can do to try to prevent this problem?

    Have you tried to add this before you call CreateToolhelp32Snapshot ?

    #ifndef TH32CS_SNAPNOHEAPS
    #define TH32CS_SNAPNOHEAPS 0x40000000
    #endif

    Best Regards,

    Baron Bi


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, January 11, 2018 8:26 AM