memory management - how fast is memory?
Posted: Sat Dec 16, 2006 2:58 am
I thought of a way of allocating memory, that would avoid any fragmentation, but is slow.
Think of memory like water in a cup. When you allocate memory, you poor water into the cup. When you want to free memory, you remove part of the water, and the rest flows to the bottom.
I'm not sure if that's the clearest example, but my idea of a memory manager is the following:
When freeing memory, the pointers above the freed memory will be rendered invalid, I haven't thought of a solution to this problem yet.
Does any one know how the garbage collection in Java and .NET work? I like the idea in .NET of ArrayLists, where any object of any size can be added or removed from any point within the array without any (noticable) fragmentation, and I was thinking something along that sort could be applied in an operating system.
Think of memory like water in a cup. When you allocate memory, you poor water into the cup. When you want to free memory, you remove part of the water, and the rest flows to the bottom.
I'm not sure if that's the clearest example, but my idea of a memory manager is the following:
- A variable, such as memStackEnd, initially refers to the beginning of the free space.
When malloc is called, memory is allocated at the position memStackEnd is located at, and memStackEnd is increased by the size allocated, referring to the beginning of the free memory.
When free is called, all memory above the block is automatically copied down.
When freeing memory, the pointers above the freed memory will be rendered invalid, I haven't thought of a solution to this problem yet.
Does any one know how the garbage collection in Java and .NET work? I like the idea in .NET of ArrayLists, where any object of any size can be added or removed from any point within the array without any (noticable) fragmentation, and I was thinking something along that sort could be applied in an operating system.