Avoid 32-bit integer overflow.

Only cast down to an integer once the value has been divided by
MEGABYTES.
Merge pull request #5 from gkopff/bugfix/heap

Avoid 32-bit integer overflow.