rust-osdev / linked-list-allocator

Apache License 2.0
219 stars 53 forks source link

Release extended memory #57

Open Andy-Python-Programmer opened 2 years ago

Andy-Python-Programmer commented 2 years ago

Add a way to release extended memory since it might be the case where one allocates a large amount of memory temporarily and then never needs the allocate such large amount of memory and releasing memory is a must in this situation. So, it would be reasonable to have a function such as release_memory which takes in a closure that internally the allocater calls if a hole is available at the end of the heap and the actual memory can be freed.

Other ways?

Another way to accomplish this without changes to the allocator to itself (but will be pain) is to make the caller free the memory itself and allocate a block of memory at that location on a page fault (on the next allocation if required). Like kernel-heap-on-demand-paging and inefficient :^).

phil-opp commented 2 years ago

Sounds like a reasonable feature, I'm happy to merge a PR for this.