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. allocating object in global storage

allocating object in global storage

Scheduled Pinned Locked Moved C / C++ / MFC
data-structures
7 Posts 4 Posters 1 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.
  • F Offline
    F Offline
    ForNow
    wrote on last edited by
    #1

    I am doing interprocess communication bwtween a, DOS console program and a windows program using named pipes I need to allocate an object that will remain active while communication is going on between the DOS consile app and the Windows I know that typically object is allocated on the stack E.g however if I use the new operator would that Leave the object alkocated until I do a delete

    L T 3 Replies Last reply
    0
    • F ForNow

      I am doing interprocess communication bwtween a, DOS console program and a windows program using named pipes I need to allocate an object that will remain active while communication is going on between the DOS consile app and the Windows I know that typically object is allocated on the stack E.g however if I use the new operator would that Leave the object alkocated until I do a delete

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

      ForNow wrote:

      if I use the new operator would that
      Leave the object alkocated until I do a delete

      Yes - see here[^].

      Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness

      1 Reply Last reply
      0
      • F ForNow

        I am doing interprocess communication bwtween a, DOS console program and a windows program using named pipes I need to allocate an object that will remain active while communication is going on between the DOS consile app and the Windows I know that typically object is allocated on the stack E.g however if I use the new operator would that Leave the object alkocated until I do a delete

        T Offline
        T Offline
        ThatsAlok
        wrote on last edited by
        #3

        what type of object are you talking about, is it class-object or any primitive type. in both case you can take services of auto_ptr and stl::list class to keep you object alive between communication and once your program exit, stl and auto_ptr will take care of destruction of your object.

        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
        Never mind - my own stupidity is the source of every "problem" - Mixture

        cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

        1 Reply Last reply
        0
        • F ForNow

          I am doing interprocess communication bwtween a, DOS console program and a windows program using named pipes I need to allocate an object that will remain active while communication is going on between the DOS consile app and the Windows I know that typically object is allocated on the stack E.g however if I use the new operator would that Leave the object alkocated until I do a delete

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

          You will need to look at the various ways of sharing data between processes, it can be a little complicated. When you use the new opperator you are allocating storage on the heap, however each process has its own heap, and the addresses in one process' heap and not usually accessible to another process, but the can be done using interprocess messaging. Windows hooks are another very powerful way for processes to share memory, but there is no 'global' memory in windows. And yes, you need to use delete to free the memory.

          ============================== Nothing to say.

          F 1 Reply Last reply
          0
          • L Lost User

            You will need to look at the various ways of sharing data between processes, it can be a little complicated. When you use the new opperator you are allocating storage on the heap, however each process has its own heap, and the addresses in one process' heap and not usually accessible to another process, but the can be done using interprocess messaging. Windows hooks are another very powerful way for processes to share memory, but there is no 'global' memory in windows. And yes, you need to use delete to free the memory.

            ============================== Nothing to say.

            F Offline
            F Offline
            ForNow
            wrote on last edited by
            #5

            I am not looking for a method of communicationg between process for that I am using named pipes What I am looking for is persistent storage storage that will remain allocated between the interprcess communocation calls

            C L 2 Replies Last reply
            0
            • F ForNow

              I am not looking for a method of communicationg between process for that I am using named pipes What I am looking for is persistent storage storage that will remain allocated between the interprcess communocation calls

              C Offline
              C Offline
              Chuck OToole
              wrote on last edited by
              #6

              Dude, I'm sure *you* know what you're talking about but it's not coming through in your posts. You have 2 programs, a "Client" and a "Server" using pipes. You have a "System" where these two program are running. Where do you want this "persistent" object to live, in one program or the other or in the operating system (Windows)? What do you want this object for? Depending on what you are going to do with the object, some objects are better than others. Unless you are clear as to what you want it for and where it's to live, you will get some pretty unstatisfying suggestions, like "Open a file, that'll persist"

              1 Reply Last reply
              0
              • F ForNow

                I am not looking for a method of communicationg between process for that I am using named pipes What I am looking for is persistent storage storage that will remain allocated between the interprcess communocation calls

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

                OK, use 'new' and 'delete' (malloc and free) for persistent storage, or you can declare global storage during the life of the process by declaring a global array (you declare it outside of any functions normally just after where you include header files).

                ============================== Nothing to say.

                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