%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% AcquireAlignedMemory() returns a pointer to a block of memory at least size
-% bytes whose address is aligned on a page boundary.
+% bytes whose address is aligned on a cache line or page boundary.
%
% The format of the AcquireAlignedMemory method is:
%
if (HeapOverflowSanityCheck(count,quantum) != MagickFalse)
return((void *) NULL);
memory=NULL;
- alignment=GetMagickPageSize();
size=count*quantum;
+ alignment=CACHE_LINE_SIZE;
+ if (size > (GetMagickPageSize() >> 1))
+ alignment=GetMagickPageSize();
extent=AlignedExtent(size,CACHE_LINE_SIZE);
if ((size == 0) || (extent < size))
return((void *) NULL);