How do I allocate memory correctly?
Posted: Thu Apr 30, 2020 7:49 pm
Hi.
I already have a ready-made memory Manager that divides memory into 4 KB pages and allocates it on request.
If I call kmalloc (10), it will allocate one page of 4096 bytes, and if kmalloc(5000), it will allocate 2 pages of 4096 bytes.
I was wondering if it is correct to allocate as many as 4096 bytes to a query, for example, 10 bytes. On the one hand, this makes memory managers work faster, but on the other hand, a lot of memory is wasted.
Is this approach correct? Maybe you should change something?
Thanks.
I already have a ready-made memory Manager that divides memory into 4 KB pages and allocates it on request.
If I call kmalloc (10), it will allocate one page of 4096 bytes, and if kmalloc(5000), it will allocate 2 pages of 4096 bytes.
I was wondering if it is correct to allocate as many as 4096 bytes to a query, for example, 10 bytes. On the one hand, this makes memory managers work faster, but on the other hand, a lot of memory is wasted.
Is this approach correct? Maybe you should change something?
Thanks.