Three typical memory allocation algorithms are:
First Fit Memory blocks are ordered. Choose the first block large enough. Best Fit Choose the smallest free block which is large enough. Worst Fit Choose the largest block.
In all cases, if the chosen free block is not the exact size, split off the amount needed, leaving a smaller free block of the extra amount. This eliminates all internal fragmentation.
Unfortunately, these allocation strategies cannot avoid external fragmentation.