Comments (2)
First of all, my apologies for the soooooo late reply. I've been really busy the last weeks. I am sorry.
Regarding your first question, the answer is Yes. You can use one single struct for both purposes. But, this will (unnecessarily) increase the amount of data used for the FreeList nodes and thus reducing the amount of data that could be potentially used by the allocator. However, is not that bad.
The answer to your second question is Yes, we should make sure that we have enough space to actually create a new node. I totally agree. (Bug spotted). In fact, if there's not enough space we should (a) reject the creation of the data block requested or (b) increase the FreeList size by performing an additional memory allocation by calling malloc.
Thanks for sharing your thoughts!
EDIT:
I've jut read your comment again and at the end you say:
I am just trying to figure out if it is necessary to have two headers and storing the block size repeatedly.
I would like to make sure that there's no confusion about this: Each block size is stored only once in either an AdditionalHeader or a FreeHeader. I decided to use to different structs to make it easier to understand. Maybe it wasnt the right decision...
from memory-allocators.
Secondly, in the alloc implementation of FreeListAllocator. When adding new block/node due to rest of available memory. Checking "rest > 0" is not enough I believe, because every block must have a header. I checked "rest > sizeof(AdditionalHeader)" instead of "rest > 0", since I only have one additional header. If 0 < rest < sizeof(AdditionalHeader) then we cannot make it a block right?
I solved this problem using if (rest >= (sizeof(Node)+alignment)) instead if (rest > 0).
from memory-allocators.
Related Issues (20)
- There's a little confusion about the diagram HOT 4
- Can you share rest ppt of Dynamic memory ? HOT 2
- FreeListAllocator :: FindBest() question HOT 1
- I made mistake, sorry
- Bug in Free List Allocator on 32bit systems HOT 3
- Build errors HOT 3
- How to use allocated memory HOT 3
- why use virtual method HOT 1
- find a small bug here HOT 2
- Make AllocationHeader::padding size_t
- StackAllocator is not performant and wastes memory on padding
- Optimize PoolAllocator initialization by adding an Offset variable?
- Found a bug in StackAllocator
- Can't compile the code. HOT 4
- add simple example HOT 1
- Error while compiling in MSVC HOT 3
- consider adding tests HOT 1
- AllocationHeader is not copied from stack to the memory position HOT 2
- Potential infinite loop caused by linked list node pointing to itself HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from memory-allocators.