Proper memory limit checking on FreeBSD. Fixes #521.