![](https://secure.gravatar.com/avatar/68cce0b6e372c2c66f4d66c6356102af.jpg?s=120&d=mm&r=g)
Hi! On Sat, Dec 21, 2024 at 8:16 PM Sergei Golubchik <serg@mariadb.org> wrote:
Hi, Monty,
MDEV-35469 Heap tables are calling mallocs to often
+ records_in_block= + (my_round_up_to_next_power((uint32) + (records_in_block * recbuffer + + sizeof(HP_PTRS) + MALLOC_OVERHEAD)/2) / + recbuffer);
Strictly speaking, it should be
(my_round_up_to_next_power(records_in_block * recbuffer + extra) - extra ) / recbuffer
Good catch. Fixing.
And why /2 ?
I don't want to allocate more memory than the user has given to heap. The /2 changes 'my_round_up_to_next_power' to 'my_round_up_to_previous_power()' I will add a comment to make this clear. I have also done some other minor adjustments to this patch to ensure that we also take properly into account the memory allocated by indexes when calculating the max number of rows. I will show you the final patch shortly. Regards, Monty