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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Heap Error

Heap Error

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++data-structuresperformance
8 Posts 5 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.
  • A Offline
    A Offline
    ashwath1979
    wrote on last edited by
    #1

    Hi All, I am running an application which is a form view application.I am allocating memory of size 160kb in a for loop .I am allocating memory at the begining of for loop for each iteration and freeing it at the end of each iteration.I have 133 such iteration.But i am facing a problem.In the 9th iteration when i am trying to allocate a memory using malloc the application crashes. I am getting the following messsage in the output window.

    HEAP[TEST.exe]: HEAP: Free Heap block 3f277a8 modified at 3f27850 after it was freed

    I am getting the following messages in the call stack window:

    ntdll.dll!7c90120e()
    [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
    ntdll.dll!7c96e139()
    ntdll.dll!7c94b535()
    ntdll.dll!7c927573()
    ntdll.dll!7c91005d()
    ntdll.dll!7c927784()
    ntdll.dll!7c927573()

    TEST.exe!_heap_alloc_base(unsigned int size=160036) Line 105 + 0x28 bytes C
    TEST.exe!_heap_alloc_dbg_impl(unsigned int nSize=160000, int nBlockUse=1, const char * szFileName=0x00000000, int nLine=0, int * errno_tmp=0x015cf02c) Line 427 + 0x9 bytes C++
    TEST.exe!_nh_malloc_dbg_impl(unsigned int nSize=160000, int nhFlag=0, int nBlockUse=1, const char * szFileName=0x00000000, int nLine=0, int * errno_tmp=0x015cf02c) Line 239 + 0x19 bytes C++
    TEST.exe!_nh_malloc_dbg(unsigned int nSize=160000, int nhFlag=0, int nBlockUse=1, const char * szFileName=0x00000000, int nLine=0) Line 296 + 0x1d bytes C++
    TEST.exe!malloc(unsigned int nSize=160000) Line 56 + 0x15 bytes C++
    TEST.exe!TEST_IDP_FUNC1(unsigned char * pucSrcImg=0x07200068, unsigned char * pucDstImg=0x059d4d68, unsigned short uiSrcRows=400, unsigned short uiSrcCols=400, TBoundBox * pstBoundBox=0x05bd8318) Line 529 + 0x11 bytes C
    TEST.exe!TEST_IDP_FUNC2(unsigned char * pucSrcImg=0x05aecc58, unsigned char * pucDstImg=0x03f00690, unsigned short uiSrcRows=400, unsigned short uiSrcCols=400, unsigned short uiDstRows=400, unsigned short uiDstCols=400, TBoundBox * pstBoundBox=0x05bd8318) Line 4117 + 0x1b bytes C
    TEST.exe!CTEST::FUNC3(CTESTImage * objSrcImage=0x03e726c8, CTESTImage * objDstnImage=0x03e7a050, unsigned char * pucDstImg=0x03f00690) Line 107 + 0x25 bytes C++
    TEST.exe!CTESTView::FUNC4() Line 8346 C++
    TEST.exe!_AfxDispatchCmdMsg(CCmdTarget * pTarget=0x0039c900, unsigned int nID=32902, int nCode=0, void (void)* pfn=0x00401276, void * pExtra=0x00000000, unsigned int nSig=57, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000) Line 82 C++
    TEST.exe!CCmdTarget::OnCmdM

    C _ G 3 Replies Last reply
    0
    • A ashwath1979

      Hi All, I am running an application which is a form view application.I am allocating memory of size 160kb in a for loop .I am allocating memory at the begining of for loop for each iteration and freeing it at the end of each iteration.I have 133 such iteration.But i am facing a problem.In the 9th iteration when i am trying to allocate a memory using malloc the application crashes. I am getting the following messsage in the output window.

      HEAP[TEST.exe]: HEAP: Free Heap block 3f277a8 modified at 3f27850 after it was freed

      I am getting the following messages in the call stack window:

      ntdll.dll!7c90120e()
      [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
      ntdll.dll!7c96e139()
      ntdll.dll!7c94b535()
      ntdll.dll!7c927573()
      ntdll.dll!7c91005d()
      ntdll.dll!7c927784()
      ntdll.dll!7c927573()

      TEST.exe!_heap_alloc_base(unsigned int size=160036) Line 105 + 0x28 bytes C
      TEST.exe!_heap_alloc_dbg_impl(unsigned int nSize=160000, int nBlockUse=1, const char * szFileName=0x00000000, int nLine=0, int * errno_tmp=0x015cf02c) Line 427 + 0x9 bytes C++
      TEST.exe!_nh_malloc_dbg_impl(unsigned int nSize=160000, int nhFlag=0, int nBlockUse=1, const char * szFileName=0x00000000, int nLine=0, int * errno_tmp=0x015cf02c) Line 239 + 0x19 bytes C++
      TEST.exe!_nh_malloc_dbg(unsigned int nSize=160000, int nhFlag=0, int nBlockUse=1, const char * szFileName=0x00000000, int nLine=0) Line 296 + 0x1d bytes C++
      TEST.exe!malloc(unsigned int nSize=160000) Line 56 + 0x15 bytes C++
      TEST.exe!TEST_IDP_FUNC1(unsigned char * pucSrcImg=0x07200068, unsigned char * pucDstImg=0x059d4d68, unsigned short uiSrcRows=400, unsigned short uiSrcCols=400, TBoundBox * pstBoundBox=0x05bd8318) Line 529 + 0x11 bytes C
      TEST.exe!TEST_IDP_FUNC2(unsigned char * pucSrcImg=0x05aecc58, unsigned char * pucDstImg=0x03f00690, unsigned short uiSrcRows=400, unsigned short uiSrcCols=400, unsigned short uiDstRows=400, unsigned short uiDstCols=400, TBoundBox * pstBoundBox=0x05bd8318) Line 4117 + 0x1b bytes C
      TEST.exe!CTEST::FUNC3(CTESTImage * objSrcImage=0x03e726c8, CTESTImage * objDstnImage=0x03e7a050, unsigned char * pucDstImg=0x03f00690) Line 107 + 0x25 bytes C++
      TEST.exe!CTESTView::FUNC4() Line 8346 C++
      TEST.exe!_AfxDispatchCmdMsg(CCmdTarget * pTarget=0x0039c900, unsigned int nID=32902, int nCode=0, void (void)* pfn=0x00401276, void * pExtra=0x00000000, unsigned int nSig=57, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000) Line 82 C++
      TEST.exe!CCmdTarget::OnCmdM

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      Code Watson, we need code. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      C 1 Reply Last reply
      0
      • C CPallini

        Code Watson, we need code. :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        C Offline
        C Offline
        Chris Meech
        wrote on last edited by
        #3

        Code, plz. Urgent. Doesn't that work? :)

        Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]

        C 1 Reply Last reply
        0
        • A ashwath1979

          Hi All, I am running an application which is a form view application.I am allocating memory of size 160kb in a for loop .I am allocating memory at the begining of for loop for each iteration and freeing it at the end of each iteration.I have 133 such iteration.But i am facing a problem.In the 9th iteration when i am trying to allocate a memory using malloc the application crashes. I am getting the following messsage in the output window.

          HEAP[TEST.exe]: HEAP: Free Heap block 3f277a8 modified at 3f27850 after it was freed

          I am getting the following messages in the call stack window:

          ntdll.dll!7c90120e()
          [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
          ntdll.dll!7c96e139()
          ntdll.dll!7c94b535()
          ntdll.dll!7c927573()
          ntdll.dll!7c91005d()
          ntdll.dll!7c927784()
          ntdll.dll!7c927573()

          TEST.exe!_heap_alloc_base(unsigned int size=160036) Line 105 + 0x28 bytes C
          TEST.exe!_heap_alloc_dbg_impl(unsigned int nSize=160000, int nBlockUse=1, const char * szFileName=0x00000000, int nLine=0, int * errno_tmp=0x015cf02c) Line 427 + 0x9 bytes C++
          TEST.exe!_nh_malloc_dbg_impl(unsigned int nSize=160000, int nhFlag=0, int nBlockUse=1, const char * szFileName=0x00000000, int nLine=0, int * errno_tmp=0x015cf02c) Line 239 + 0x19 bytes C++
          TEST.exe!_nh_malloc_dbg(unsigned int nSize=160000, int nhFlag=0, int nBlockUse=1, const char * szFileName=0x00000000, int nLine=0) Line 296 + 0x1d bytes C++
          TEST.exe!malloc(unsigned int nSize=160000) Line 56 + 0x15 bytes C++
          TEST.exe!TEST_IDP_FUNC1(unsigned char * pucSrcImg=0x07200068, unsigned char * pucDstImg=0x059d4d68, unsigned short uiSrcRows=400, unsigned short uiSrcCols=400, TBoundBox * pstBoundBox=0x05bd8318) Line 529 + 0x11 bytes C
          TEST.exe!TEST_IDP_FUNC2(unsigned char * pucSrcImg=0x05aecc58, unsigned char * pucDstImg=0x03f00690, unsigned short uiSrcRows=400, unsigned short uiSrcCols=400, unsigned short uiDstRows=400, unsigned short uiDstCols=400, TBoundBox * pstBoundBox=0x05bd8318) Line 4117 + 0x1b bytes C
          TEST.exe!CTEST::FUNC3(CTESTImage * objSrcImage=0x03e726c8, CTESTImage * objDstnImage=0x03e7a050, unsigned char * pucDstImg=0x03f00690) Line 107 + 0x25 bytes C++
          TEST.exe!CTESTView::FUNC4() Line 8346 C++
          TEST.exe!_AfxDispatchCmdMsg(CCmdTarget * pTarget=0x0039c900, unsigned int nID=32902, int nCode=0, void (void)* pfn=0x00401276, void * pExtra=0x00000000, unsigned int nSig=57, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000) Line 82 C++
          TEST.exe!CCmdTarget::OnCmdM

          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          ashwath1979 wrote:

          I am allocating memory of size 160kb in a for loop

          Don't do this. Use a standard STL container like vector instead. The container will manage the heap allocations for you.

          «_Superman_» I love work. It gives me something to do between weekends.
          Microsoft MVP (Visual C++)

          1 Reply Last reply
          0
          • C Chris Meech

            Code, plz. Urgent. Doesn't that work? :)

            Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]

            C Offline
            C Offline
            CPallini
            wrote on last edited by
            #5

            Chris Meech wrote:

            I am Canadian. [heard in a local bar]

            I don't get it (I feel stupid...). :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            C 1 Reply Last reply
            0
            • C CPallini

              Chris Meech wrote:

              I am Canadian. [heard in a local bar]

              I don't get it (I feel stupid...). :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              C Offline
              C Offline
              Chris Meech
              wrote on last edited by
              #6

              Canadian Along with being a name for people like me who live in Canada, it also happens to be a popular beer[^]. Several years ago Molson's had a really good TV commercial that extolled the virtues of being a Canadian (as opposed to being American). :) Currently there's a good commercial about how "We have more square footage of awesomeness than any other country". :) Of course, most people just think of us as a land of polar bears, igloos, beavers and seal bashers. :)

              Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]

              C 1 Reply Last reply
              0
              • C Chris Meech

                Canadian Along with being a name for people like me who live in Canada, it also happens to be a popular beer[^]. Several years ago Molson's had a really good TV commercial that extolled the virtues of being a Canadian (as opposed to being American). :) Currently there's a good commercial about how "We have more square footage of awesomeness than any other country". :) Of course, most people just think of us as a land of polar bears, igloos, beavers and seal bashers. :)

                Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]

                C Offline
                C Offline
                CPallini
                wrote on last edited by
                #7

                Ah, OK. Thank you. :beer:

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                [My articles]

                1 Reply Last reply
                0
                • A ashwath1979

                  Hi All, I am running an application which is a form view application.I am allocating memory of size 160kb in a for loop .I am allocating memory at the begining of for loop for each iteration and freeing it at the end of each iteration.I have 133 such iteration.But i am facing a problem.In the 9th iteration when i am trying to allocate a memory using malloc the application crashes. I am getting the following messsage in the output window.

                  HEAP[TEST.exe]: HEAP: Free Heap block 3f277a8 modified at 3f27850 after it was freed

                  I am getting the following messages in the call stack window:

                  ntdll.dll!7c90120e()
                  [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
                  ntdll.dll!7c96e139()
                  ntdll.dll!7c94b535()
                  ntdll.dll!7c927573()
                  ntdll.dll!7c91005d()
                  ntdll.dll!7c927784()
                  ntdll.dll!7c927573()

                  TEST.exe!_heap_alloc_base(unsigned int size=160036) Line 105 + 0x28 bytes C
                  TEST.exe!_heap_alloc_dbg_impl(unsigned int nSize=160000, int nBlockUse=1, const char * szFileName=0x00000000, int nLine=0, int * errno_tmp=0x015cf02c) Line 427 + 0x9 bytes C++
                  TEST.exe!_nh_malloc_dbg_impl(unsigned int nSize=160000, int nhFlag=0, int nBlockUse=1, const char * szFileName=0x00000000, int nLine=0, int * errno_tmp=0x015cf02c) Line 239 + 0x19 bytes C++
                  TEST.exe!_nh_malloc_dbg(unsigned int nSize=160000, int nhFlag=0, int nBlockUse=1, const char * szFileName=0x00000000, int nLine=0) Line 296 + 0x1d bytes C++
                  TEST.exe!malloc(unsigned int nSize=160000) Line 56 + 0x15 bytes C++
                  TEST.exe!TEST_IDP_FUNC1(unsigned char * pucSrcImg=0x07200068, unsigned char * pucDstImg=0x059d4d68, unsigned short uiSrcRows=400, unsigned short uiSrcCols=400, TBoundBox * pstBoundBox=0x05bd8318) Line 529 + 0x11 bytes C
                  TEST.exe!TEST_IDP_FUNC2(unsigned char * pucSrcImg=0x05aecc58, unsigned char * pucDstImg=0x03f00690, unsigned short uiSrcRows=400, unsigned short uiSrcCols=400, unsigned short uiDstRows=400, unsigned short uiDstCols=400, TBoundBox * pstBoundBox=0x05bd8318) Line 4117 + 0x1b bytes C
                  TEST.exe!CTEST::FUNC3(CTESTImage * objSrcImage=0x03e726c8, CTESTImage * objDstnImage=0x03e7a050, unsigned char * pucDstImg=0x03f00690) Line 107 + 0x25 bytes C++
                  TEST.exe!CTESTView::FUNC4() Line 8346 C++
                  TEST.exe!_AfxDispatchCmdMsg(CCmdTarget * pTarget=0x0039c900, unsigned int nID=32902, int nCode=0, void (void)* pfn=0x00401276, void * pExtra=0x00000000, unsigned int nSig=57, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000) Line 82 C++
                  TEST.exe!CCmdTarget::OnCmdM

                  G Offline
                  G Offline
                  Gary R Wheeler
                  wrote on last edited by
                  #8

                  This error means that your application has freed the memory but continued to use it or modify it after doing so. This can happen in a Windows application if you try to pass the memory to a window (like an edit box or other control) via the message queue using PostMessage, or an API call that uses PostMessage.

                  Software Zen: delete this;
                  Fold With Us![^]

                  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