Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Memory Allocation Error 998

Memory Allocation Error 998

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharpvisual-studioperformancequestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Richard Andrew x64R Offline
    Richard Andrew x64R Offline
    Richard Andrew x64
    wrote on last edited by
    #1

    I'm working on a straight C program in Visual Studio 6.0. I added a few calls to malloc() today, and malloc fails every time with a NULL return value. GetLastError() returns 998 - Invalid access to memory location. The process is using only about 5 MB of RAM when this occurs, and I've restarted XP several times without curing the problem. No other process on the system shows any signs of running out of memory. When I replace calls to malloc with calls to HeapAlloc(), the program runs fine. Can anyone think of a reason why malloc might be failing?

    S K L 3 Replies Last reply
    0
    • Richard Andrew x64R Richard Andrew x64

      I'm working on a straight C program in Visual Studio 6.0. I added a few calls to malloc() today, and malloc fails every time with a NULL return value. GetLastError() returns 998 - Invalid access to memory location. The process is using only about 5 MB of RAM when this occurs, and I've restarted XP several times without curing the problem. No other process on the system shows any signs of running out of memory. When I replace calls to malloc with calls to HeapAlloc(), the program runs fine. Can anyone think of a reason why malloc might be failing?

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      Are you absolutely sure it's malloc that's causing that error code (use SetLastError to reset the thread's error code immediately before the malloc call)? If so, all I can suggest is single-stepping through malloc (you have got the CRT source installed haven't you?) in the debugger and seeing where it fails. It's not so tricky :-) I'm afraid I can't help further, as I haven't had VC6 installed anywhere for ages (and don't even know where I could lay my hands on the install media).

      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

      Richard Andrew x64R 1 Reply Last reply
      0
      • S Stuart Dootson

        Are you absolutely sure it's malloc that's causing that error code (use SetLastError to reset the thread's error code immediately before the malloc call)? If so, all I can suggest is single-stepping through malloc (you have got the CRT source installed haven't you?) in the debugger and seeing where it fails. It's not so tricky :-) I'm afraid I can't help further, as I haven't had VC6 installed anywhere for ages (and don't even know where I could lay my hands on the install media).

        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

        Richard Andrew x64R Offline
        Richard Andrew x64R Offline
        Richard Andrew x64
        wrote on last edited by
        #3

        Thanks, Stuart. I will try stepping through again. But I find it more or less fruitless because I haven't a clue how the CRT operates, and I find it very difficult to read that code with all the underscores!

        1 Reply Last reply
        0
        • Richard Andrew x64R Richard Andrew x64

          I'm working on a straight C program in Visual Studio 6.0. I added a few calls to malloc() today, and malloc fails every time with a NULL return value. GetLastError() returns 998 - Invalid access to memory location. The process is using only about 5 MB of RAM when this occurs, and I've restarted XP several times without curing the problem. No other process on the system shows any signs of running out of memory. When I replace calls to malloc with calls to HeapAlloc(), the program runs fine. Can anyone think of a reason why malloc might be failing?

          K Offline
          K Offline
          ky_rerun
          wrote on last edited by
          #4

          Can you build a new program that only uses malloc and see what happens. If you view the assembly does malloc actually get called. Can you post the code.


          a programmer traped in a thugs body

          Richard Andrew x64R 1 Reply Last reply
          0
          • K ky_rerun

            Can you build a new program that only uses malloc and see what happens. If you view the assembly does malloc actually get called. Can you post the code.


            a programmer traped in a thugs body

            Richard Andrew x64R Offline
            Richard Andrew x64R Offline
            Richard Andrew x64
            wrote on last edited by
            #5

            Thanks for your interest. I will look at the assembly as you suggest. I can't post the code until I get to work tomorrow, but I'll do so if I can't solve it on my own.

            1 Reply Last reply
            0
            • Richard Andrew x64R Richard Andrew x64

              I'm working on a straight C program in Visual Studio 6.0. I added a few calls to malloc() today, and malloc fails every time with a NULL return value. GetLastError() returns 998 - Invalid access to memory location. The process is using only about 5 MB of RAM when this occurs, and I've restarted XP several times without curing the problem. No other process on the system shows any signs of running out of memory. When I replace calls to malloc with calls to HeapAlloc(), the program runs fine. Can anyone think of a reason why malloc might be failing?

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              me sathish u r allocating more mem tht the system can't hold using malloc. so only u can use heap functions to allocate more. :suss::suss:

              ya

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups