How to write a Un-fixed size memory pool ?
-
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 ?
-
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 ?
-
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 ?
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.
-
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.
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.
-
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.
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.
-
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.
-
Oh my God. If there have one hundred different size, I will create one hundred memory pool? :(
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?