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. 'new' limit

'new' limit

Scheduled Pinned Locked Moved C / C++ / MFC
helpperformancequestion
8 Posts 2 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.
  • E Offline
    E Offline
    Erik Hammar
    wrote on last edited by
    #1

    Hi, all you happy coders I Hope somebody can help me with this problem I am having: In my program i try to allocate about 500KB (in smaller pieces) with the new operator, but it hangs in some function called '__sbh_alloc_block'... Is this because I can't get more memory from windows...? Thanks in advance, Erik Hammar :confused:

    N 1 Reply Last reply
    0
    • E Erik Hammar

      Hi, all you happy coders I Hope somebody can help me with this problem I am having: In my program i try to allocate about 500KB (in smaller pieces) with the new operator, but it hangs in some function called '__sbh_alloc_block'... Is this because I can't get more memory from windows...? Thanks in advance, Erik Hammar :confused:

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      Erik Hammar wrote: i try to allocate about 500KB (in smaller pieces) From that sentence I assume you have a loop of some kind where you repeatedly call new till you get 500 KB is several smaller blocks [or so we assume] Now are you sure your loop is looping the right number of times. perhaps it's a sort of endless loop! Nish Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut

      E 1 Reply Last reply
      0
      • N Nish Nishant

        Erik Hammar wrote: i try to allocate about 500KB (in smaller pieces) From that sentence I assume you have a loop of some kind where you repeatedly call new till you get 500 KB is several smaller blocks [or so we assume] Now are you sure your loop is looping the right number of times. perhaps it's a sort of endless loop! Nish Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut

        E Offline
        E Offline
        Erik Hammar
        wrote on last edited by
        #3

        No it's not a loop... I create instances of about 5 classes, which each allocate one or two blocks of memory...

        N 1 Reply Last reply
        0
        • E Erik Hammar

          No it's not a loop... I create instances of about 5 classes, which each allocate one or two blocks of memory...

          N Offline
          N Offline
          Nish Nishant
          wrote on last edited by
          #4

          After how many sucessful 'new's do you get the error? Nish Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut

          E 1 Reply Last reply
          0
          • N Nish Nishant

            After how many sucessful 'new's do you get the error? Nish Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut

            E Offline
            E Offline
            Erik Hammar
            wrote on last edited by
            #5

            I get it after 5 times... ... byte *bmpdata = new byte[256*240]; memsize 1 > 128KB class1 = new CClass1(memsize1) (inside CClass1's constructor) data = new byte[memsize1] memsize 2 > 128KB class2 = new CClass2(memsize2) (inside CClass2's constructor) data = new byte[memsize2] class3 = new CClass3 - this is where it crashes (before the actual constructor of CClass3) ... Seems really strange to me, that this hangs the program, and not only gives me a NULL pointer!

            N 1 Reply Last reply
            0
            • E Erik Hammar

              I get it after 5 times... ... byte *bmpdata = new byte[256*240]; memsize 1 > 128KB class1 = new CClass1(memsize1) (inside CClass1's constructor) data = new byte[memsize1] memsize 2 > 128KB class2 = new CClass2(memsize2) (inside CClass2's constructor) data = new byte[memsize2] class3 = new CClass3 - this is where it crashes (before the actual constructor of CClass3) ... Seems really strange to me, that this hangs the program, and not only gives me a NULL pointer!

              N Offline
              N Offline
              Nish Nishant
              wrote on last edited by
              #6

              Well I cant even make any guesses from that. But try creating the CClass3 object first and then create CClass1 and CClass2. Now if it still gives an error when you create the CClass3 the problem must be with something you are doing in the CClass3 constructor, but if the trouble happens with the third new then we are again nowhere :-( Try this out anyway. And if possible post the CClass1/2/3 constructor code as well. Also how is the data member-variable defined in these classes? Nish Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut

              E 1 Reply Last reply
              0
              • N Nish Nishant

                Well I cant even make any guesses from that. But try creating the CClass3 object first and then create CClass1 and CClass2. Now if it still gives an error when you create the CClass3 the problem must be with something you are doing in the CClass3 constructor, but if the trouble happens with the third new then we are again nowhere :-( Try this out anyway. And if possible post the CClass1/2/3 constructor code as well. Also how is the data member-variable defined in these classes? Nish Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut

                E Offline
                E Offline
                Erik Hammar
                wrote on last edited by
                #7

                Strange... moving the class3 creation code to the top, seems to eliminate the problem. That's strange, because the class3 doesn't even touch the class1 and class2 Anyway, Thanks for your concern!

                N 1 Reply Last reply
                0
                • E Erik Hammar

                  Strange... moving the class3 creation code to the top, seems to eliminate the problem. That's strange, because the class3 doesn't even touch the class1 and class2 Anyway, Thanks for your concern!

                  N Offline
                  N Offline
                  Nish Nishant
                  wrote on last edited by
                  #8

                  Erik, I think you should not be complacent about the error being removed. We still don't know why it crashed before. A bug that has been hidden but not removed can be very deadly. Good luck. Nish Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut

                  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