macOS High Memory Usage

Using 2017r2.1 i compiled a 64bit app with nothing in it, just the window, and ran it.
Starting memory 15megs. I then resized to 5K screen size. Memory jumps to 120megs. Resize back to starting size ~25 megs, resizing back up to full screen i see 220megs being used. Close the window (leaving the app running) it sits at 112 megs.

Same app on Surface pro 4, windows 10, app uses 7 megs.

Both have hiDPI support on.

Any idea on why empty window is using so much memory on macOS?

I am running OSX 10.12.6

Caching, IMHO. Modern macOS like to cache everything and anything, hold onto it until the very last moment. Right now Apple uses Triple buffering, each control has a display cache, each window has a display cache and of course each screen has a display cache.

Looks like your right there, just tried it with a text editor app and resizing window effects memory usage a lot.
Good to know.

Most of time it doesn’t cause any issues, although if your installation of the macOS is borked somehow (mine was), the machine can crash when exceeding the physical amount of memory (which happens a lot for me).

I forgot to add that if you use Apple’s imaging API the images are ‘sorta’ cached into memory too. I say sorta, because it caches the image at the display size in memory, but when you want to draw it at a different size, it re-reads from disk, creates a cache that size and stores that in memory.

That’s odd. OSX (and all OS’s for that matter) should start swapping if more memory is used than physically available. Not crash.

Oh trust me, when it’s swapping you can really feel it. Yeah it shouldn’t crash, but it used to until I did a clean install. Now it just chuggs when I over reach, just t’other day I was using over 64GB (AutoRelease issue not releasing while a thread is running).