Rewrite palloc code so that it only touches the first 4 MB of RAM.