Memory Manager, Garbage Collection, Recycle Bin, Defrag
Posted: Thu Jul 07, 2016 8:27 pm
So, I've mentioned before, I think, that I had originally set out, seven years ago now, to build an OS that treated system RAM and hard drive space the same way, so that it could use common logic to do things like allocate and unallocate memory and clean up and defragment unused memory.
I've since learned that it's more difficult than I thought to treat all memory the same, mainly due to the block address nature of storage devices, the latency involved, and the fact that everything has to be first copied from storage into memory before it can be read.
But, this is still one of my goals, to the extent that it's actually feasible. I am now getting to the point where I am starting to think about a smarter memory manager (my current one just keeps a pointer to the next available memory address, and increments it as needed), and garbage collection. Since virtually everything in my OS is an object (essentially a struct, with a separate structure that describes the location and metadata of the struct), I am thinking about combining the memory manager and object manager/garbage collector into a single system, so that even simple memory buffers would be treated as objects, and the object structure that describes the struct / metadata could be used in place of memory tables. And objects that are no longer used can be stored in the "Recycle Bin" and reused in the future, instead of having to unallocate, reallocate and reinitialize them.
And, like your Recycle Bin on your hard drive, no clean up will need to be done at all, until you have used up all memory, and you need to start reclaiming old objects and repurposing them as new objects. And if all goes well, the objects in memory and the objects stored on disk will be stored and managed in the same way.
We'll see how well it goes. I'll be (slowly) implementing all of this stuff over the next few months. We'll see how close I can get to my goal of building a truly object oriented OS.
I've since learned that it's more difficult than I thought to treat all memory the same, mainly due to the block address nature of storage devices, the latency involved, and the fact that everything has to be first copied from storage into memory before it can be read.
But, this is still one of my goals, to the extent that it's actually feasible. I am now getting to the point where I am starting to think about a smarter memory manager (my current one just keeps a pointer to the next available memory address, and increments it as needed), and garbage collection. Since virtually everything in my OS is an object (essentially a struct, with a separate structure that describes the location and metadata of the struct), I am thinking about combining the memory manager and object manager/garbage collector into a single system, so that even simple memory buffers would be treated as objects, and the object structure that describes the struct / metadata could be used in place of memory tables. And objects that are no longer used can be stored in the "Recycle Bin" and reused in the future, instead of having to unallocate, reallocate and reinitialize them.
And, like your Recycle Bin on your hard drive, no clean up will need to be done at all, until you have used up all memory, and you need to start reclaiming old objects and repurposing them as new objects. And if all goes well, the objects in memory and the objects stored on disk will be stored and managed in the same way.
We'll see how well it goes. I'll be (slowly) implementing all of this stuff over the next few months. We'll see how close I can get to my goal of building a truly object oriented OS.