Add the LSEnvironment variable MallocNanoZone=0.

There appears to be a bug in Launch Services that causes MallocNanoZone=1 to
always be set by default for all applications [this affects applications
launched by Finder, and on restart, but not applications launched from the
Terminal]. I filed https://bugreport.apple.com/web/?problemID=42181038 to track
this.

MallocNanoZone causes libMalloc to use the nano malloc zone by default [affects
allocations <= 256 bytes]. The implementation of nano malloc never frees memory.
See https://bugs.chromium.org/p/chromium/issues/detail?id=861939#c6 for more
details.

This has been observed to cause > 1GB of wasted memory in the browser process.
Possibly a lot more when added up across all processes.

To test this:
1) Build Chrome with patch.
2) Run
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister
-f <path_to_chrome>
3) Launch Chrome from Finder
4) Use "vmmap <pid>" to observe whether there is a MALLOC_NANO summary.

Bug: 861939
Change-Id: I740bcbb006e4ce641d0dde6f6e53dcf4f032ff0b
Reviewed-on: https://chromium-review.googlesource.com/1137131
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Erik Chen <erikchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575108}
2 files changed