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. How to write a Un-fixed size memory pool ?

How to write a Un-fixed size memory pool ?

Scheduled Pinned Locked Moved C / C++ / MFC
c++performancehelptutorialquestion
7 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.
  • Y Offline
    Y Offline
    yu jian
    wrote on last edited by
    #1

    I need use the C++ to writer a memory pool to save the frame data, un-fixed size buffer. But I find that the Boost Pool only support allocate the same size memory once a time. So I want to achieve myself memory pool to support saving the not same size frame data. Is there some one meet the similiar problem ?

    J S 2 Replies Last reply
    0
    • Y yu jian

      I need use the C++ to writer a memory pool to save the frame data, un-fixed size buffer. But I find that the Boost Pool only support allocate the same size memory once a time. So I want to achieve myself memory pool to support saving the not same size frame data. Is there some one meet the similiar problem ?

      J Offline
      J Offline
      jschell
      wrote on last edited by
      #2

      A pool exists to provide management of resources. If you are not managing the size of your "memory pool" exactly what are you managing?

      1 Reply Last reply
      0
      • Y yu jian

        I need use the C++ to writer a memory pool to save the frame data, un-fixed size buffer. But I find that the Boost Pool only support allocate the same size memory once a time. So I want to achieve myself memory pool to support saving the not same size frame data. Is there some one meet the similiar problem ?

        S Offline
        S Offline
        Stefan_Lang
        wrote on last edited by
        #3

        The task you're describing is exactly what the system memory manager is built for! It can allocate objects of any size, and will organize your memory in such a way that it can handle millions of calls without serious degradation. Memory Pools take advantage of the fact that most of the time when you have lots of allocations, you always allocate objects of the same type and size. Based on that assumption, you can improve the performance of the allocation (and deallocation) process, and reduce memory fragmentation. If you can't make such assumptions, then you'd need to do exactly the same thing the system memory manager does. In other words: just use new and delete. Is there a specific reason why you think you need a pool? Maybe there are better ways to improve yur program.

        Y 1 Reply Last reply
        0
        • S Stefan_Lang

          The task you're describing is exactly what the system memory manager is built for! It can allocate objects of any size, and will organize your memory in such a way that it can handle millions of calls without serious degradation. Memory Pools take advantage of the fact that most of the time when you have lots of allocations, you always allocate objects of the same type and size. Based on that assumption, you can improve the performance of the allocation (and deallocation) process, and reduce memory fragmentation. If you can't make such assumptions, then you'd need to do exactly the same thing the system memory manager does. In other words: just use new and delete. Is there a specific reason why you think you need a pool? Maybe there are better ways to improve yur program.

          Y Offline
          Y Offline
          yu jian
          wrote on last edited by
          #4

          I need to optimize my stream player client, it will play 8 road stream in the same time. I think that if use the memory pool, it will help to reduce the usage of time about allocate memory. 30 frames every second, but H264 has I Frame P Frame. So different frames have different size. So the memory pool of boost is not suitable for my client system.

          S 1 Reply Last reply
          0
          • Y yu jian

            I need to optimize my stream player client, it will play 8 road stream in the same time. I think that if use the memory pool, it will help to reduce the usage of time about allocate memory. 30 frames every second, but H264 has I Frame P Frame. So different frames have different size. So the memory pool of boost is not suitable for my client system.

            S Offline
            S Offline
            Stefan_Lang
            wrote on last edited by
            #5

            Ok, so the sizes are in fact not freely variable, they may just vary between two (or more) different sizes. In that case, use two (or more) pools - one for each size.

            Y 1 Reply Last reply
            0
            • S Stefan_Lang

              Ok, so the sizes are in fact not freely variable, they may just vary between two (or more) different sizes. In that case, use two (or more) pools - one for each size.

              Y Offline
              Y Offline
              yu jian
              wrote on last edited by
              #6

              Oh my God. If there have one hundred different size, I will create one hundred memory pool? :(

              S 1 Reply Last reply
              0
              • Y yu jian

                Oh my God. If there have one hundred different size, I will create one hundred memory pool? :(

                S Offline
                S Offline
                Stefan_Lang
                wrote on last edited by
                #7

                I am not familiar with player streams. After your last posting my understanding was that you get Frames of very specific type (I Frame and P Frame, maybe some other frame types). I assumed that since you know these types, you deal with them in your program and of course must know their size (well, your compiler does). If that is not the case, then what do these types mean, and what is the data type you use for storing?

                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