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. Overloading operator new

Overloading operator new

Scheduled Pinned Locked Moved C / C++ / MFC
debuggingperformancequestionworkspace
4 Posts 3 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.
  • R Offline
    R Offline
    RichardS
    wrote on last edited by
    #1

    Hi, For memory stats we have overloaded the operator new in such a way that it allows us to allocate memory and store information about which module is doing it. This is all great. However, now that we have moved to a multi-threaded environment, do we need to protect the call _malloc_dbg(...) (in a debug build) and the ::operator new(...) (in non-debug) with a critical section? "Programming today is a race between software engineers striving to build bigger and better idiot-proff programs, and the Universe trying to produce bigger and better idiots. So far the Universe is winning." -- Rich Cook

    N T 2 Replies Last reply
    0
    • R RichardS

      Hi, For memory stats we have overloaded the operator new in such a way that it allows us to allocate memory and store information about which module is doing it. This is all great. However, now that we have moved to a multi-threaded environment, do we need to protect the call _malloc_dbg(...) (in a debug build) and the ::operator new(...) (in non-debug) with a critical section? "Programming today is a race between software engineers striving to build bigger and better idiot-proff programs, and the Universe trying to produce bigger and better idiots. So far the Universe is winning." -- Rich Cook

      N Offline
      N Offline
      n 0
      wrote on last edited by
      #2

      in dos one could access hardware directly because dos's singe-threaded. multi-threaded oses like windows have to take care themselves that hardware pieces are accessed by just one program at a time. this means for you that not you're allocating memory, but the os's doing it for you; you don't need any multithreading resource-locking techniques at all. Я люблю русский язикь!

      T 1 Reply Last reply
      0
      • R RichardS

        Hi, For memory stats we have overloaded the operator new in such a way that it allows us to allocate memory and store information about which module is doing it. This is all great. However, now that we have moved to a multi-threaded environment, do we need to protect the call _malloc_dbg(...) (in a debug build) and the ::operator new(...) (in non-debug) with a critical section? "Programming today is a race between software engineers striving to build bigger and better idiot-proff programs, and the Universe trying to produce bigger and better idiots. So far the Universe is winning." -- Rich Cook

        T Offline
        T Offline
        Tim Smith
        wrote on last edited by
        #3

        When you build with the MT (multithreaded) CRTL (c run time library), you will be getting the multithreaded version of new and delete which have built in locking support. You don't have to worry about it. Tim Smith I'm going to patent thought. I have yet to see any prior art.

        1 Reply Last reply
        0
        • N n 0

          in dos one could access hardware directly because dos's singe-threaded. multi-threaded oses like windows have to take care themselves that hardware pieces are accessed by just one program at a time. this means for you that not you're allocating memory, but the os's doing it for you; you don't need any multithreading resource-locking techniques at all. Я люблю русский язикь!

          T Offline
          T Offline
          Tim Smith
          wrote on last edited by
          #4

          Multithreaded operating systems do not protect your from accessing hardware at the same time. Two threads can access the same page of memory and cause all sorts of mess if locking isn't used to manage the data in the page. Tim Smith I'm going to patent thought. I have yet to see any prior art.

          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