Creating a Memory Pool

Started by
12 comments, last by Animeplayer 12 years, 10 months ago
All memory allocators rely on a system call (at some level) - unless they want to restrict themselves to the memory available on the stack. I'm not sure what point you are making?
Advertisement

As far as I am concern, both malloc and new create fragmented memory on most OS and are not particulary optimal in that sense. That doesn't mean you need to replace them, means you need to be aware on this fact.



The fragmentation must be larger than cache-line scale, correct? Where is the slowdown or the mechanisms that this fragmentation affects?
@rip-off: Nothing I was just stating he is 100% right on what he pointed out.

@PrestoChung: Memory fragmentation may affect specially on systems that do not have ""virtual memory"" (most likely embedded systems). For instance a pretty simple example, would be allocating 4 blocks of 4MB memory on a 16MB system (asssuming we can use it all), if we free 2 of those block and those are not contiguous, you will not be able to allocate 8MB block, yet you have 8MB free memory in your system. Quite simplified problem but that's the point I was trying to make (and it seems i did not explain myself correctly).

Hopefully this clarifies a bit, my point.
Cheer.


I did not know how to approach it since my college didn't teach me this.

College will not teach you everything. As I mentioned earlier, I get lots of results when searching Google for this topic. If you're having tourble, can you ask a more specific question. E.g. "I was reading here but I don't understand concept X or code fragment Y."
[/quote]
Yeah, but I want to gain access to those missing skill I want to know, especially toward game development. Sorry, I tend to confuse people by accident, I meant that, whenever I looked online about Memory Pool, I kept finding Source Codes that involved using dynamic allocations. Hodgman provided a example of a memory pool source code that I was looking for that didn't use dynamic allocations.

@Hodgman Thanks, this was the example I was looking for, just need the allocation and de-allocation of that memory pool.

This topic is closed to new replies.

Advertisement