MSYS2-packages icon indicating copy to clipboard operation
MSYS2-packages copied to clipboard

Zombie child processes eating large amounts of RAM

Open niklasholm opened this issue 5 years ago • 18 comments

rammap-ss

I've discovered that when building large amounts of packages, after a while the physical memory usage has increased drastically for no apparent reason; the physical memory usage by processes in Task Manager doesn't add up to the actual memory usage. Using RAMMap, I can see that there are many tens of thousands of terminated msys processes (bash, tee, sed, xargs etc) each taking up 24 K of memory, adding up to more than 3 GB of "lost" memory.

A similar issue is described by a Google engineer while building Chrome, although, the cause in that specific case does not apply here (I do not have CcmExec.exe running). From what I can understand, it's either caused by not closing the process handles correctly, in which case it might be a bug in msys, or it's caused by a bug in Windows. Unfortunately, the tool provided in the link does not reveal what process(es) keeps the zombies alive. Further investigation is required.

niklasholm avatar Jul 12 '18 07:07 niklasholm

No comment on this? It's quite a huge problem and very detrimental to MSYS2's use as a build environment.

niklasholm avatar Aug 03 '18 12:08 niklasholm

I haven't seen issue like that but there were many other reports, maybe are you using software which injects dlls to running processes? You might want to check https://cygwin.com/faq/faq.html#faq.using.bloda

mati865 avatar Aug 03 '18 13:08 mati865

Well, pretty much every anti-virus solution is on that list, so yeah. Currently, I'm using Avast. Is going completely without AV the only solution? What is Cygwin/msys doing that other processes without this problem (i.e. most) doing differently?

niklasholm avatar Aug 15 '18 13:08 niklasholm

Just use Windows defender. It's the only av you need. The others aren't very good IMHO.

mingwandroid avatar Aug 15 '18 13:08 mingwandroid

Windows Defender is also on that list.

niklasholm avatar Aug 15 '18 13:08 niklasholm

Heh, well, it's never caused me much trouble (unlike all the others).

mingwandroid avatar Aug 15 '18 14:08 mingwandroid

Also I'm on Windows 7, but I guess Security Essentials is basically the same minus the rootkit/boot protection. If someone could confirm that MSE doesn't interfere with msys, I'd consider giving it a go, although reluctantly because Avast has served me well and MSE lags behind in protection scores.

niklasholm avatar Aug 15 '18 14:08 niklasholm

To be honest number of false positives from MSE/Windows 10 Defender is overwhelming. Both of them would randomly detect threat when updating MSYS2 and virustotal just proves it was false positive.

mati865 avatar Aug 15 '18 16:08 mati865

So... Either way, you're screwed, nothing can be done except uninstalling all AV?

niklasholm avatar Aug 17 '18 09:08 niklasholm

@niklasholm you can exclude MSYS2 directory in your AV.

mati865 avatar Aug 17 '18 09:08 mati865

I've tried, doesn't make a damn difference.

niklasholm avatar Aug 17 '18 09:08 niklasholm

I'm not using Avast but usually there are 2 separate exclude directories, one for the scanner and one for the real-time protection.

mati865 avatar Aug 17 '18 09:08 mati865

I have never suffered a virus in my life. I take just the normal precautions but have never run a (continuously scanning) virus scanner.

The industry is largely based on snake oil (I've looked at real virus detection 'logic' it was beyond awful). They make computers far slower than they otherwise be and basically generate a load of heat based mostly on fear. Don't bother with it, John McAfee is right.

mingwandroid avatar Aug 17 '18 09:08 mingwandroid

@mati865 Yes, I've excluded it everywhere still doesn't make a difference. Disabling it completely also doesn't make a difference.

@mingwandroid Most IT security departments would disagree with you. And how do you know that if you don't have AV? Most malware does their best to hide from the user. AV stops loads of attacks, that's a fact. While it is true that very security conscious users can survive in the wild without AV, most people using a computer wouldn't.

niklasholm avatar Aug 24 '18 05:08 niklasholm

https://www.howtogeek.com/225385/what%E2%80%99s-the-best-antivirus-for-windows-10-is-windows-defender-good-enough/

This in particular gives me cause for concern:

Furthermore, security is about more than raw protection scores. Other antivirus programs may occasionally do a bit better in monthly tests, but they also come with a lot of bloat, like browser extensions that actually make you less safe, registry cleaners that are terrible and unnecesary, loads of unsafe junkware, and even the ability to track your browsing habits so they can make money. Furthermore, the way they hook themselves into your browser and operating system often causes more problems than it solves. Something that protects you against viruses but opens you up to other vectors of attack is not good security.

mingwandroid avatar Aug 24 '18 08:08 mingwandroid

@niklasholm to debug this you probably need to use ProcMon and see what DLLs you AV software is hooking.

mingwandroid avatar Aug 24 '18 08:08 mingwandroid

All that "bloat" is completely optional. I only have File Shield and Behaviour Shield installed. Besides, How-To Geek does not offer any evidence to support their claims that it makes the system less secure, so I wouldn't be too concerned. Throwing out the baby with the bathwater by getting rid of AV completely certainly does not improve security.

I'll try to find something with ProcMon.

niklasholm avatar Aug 24 '18 08:08 niklasholm

yep also running into this, the problem is that win10 changed the way of handling the standby list to be more in line with linux. the problem with that is that it does a piss poor job of it ;S sadly in msys2 case 16 gb ram is not enough my pc will grind to a halt after building two packages and even installing a memory cleaner specifically setup to free the standbylist wont help as win10 refuses to release the memory even in admin mode.

revelator avatar Dec 09 '21 08:12 revelator