Safari using 30 GB memory slowing down mac

I've been asked to help with a iMac showing the beachball and being very slow.
The problems started after installing security update 2019-002 and Safari 12.1.
The OS was Sierra (10.12) first, then updated to Mojave (10.14) which did not solve the problem.

I have a screenshot of Activity Monitor:
There I see Safari is using 30.31 GB of memory and 29.64 GB compressed memory, 8 threads, 358 ports.
Memory pressure is red, general information about memory is
8 GB physical
7.54 GB used
  953.4 MB app
  1.10 GB wired
  5.50 GB compressed
459.3 MB cached files
662.0 MB swap

All accounts on that machine are affected.

I assume that heavy swapping is going on, slowing down the iMac. (I don't know whether it has a SSD or a HDD.)
However, what I don't understand and what puzzles me, is how Safari can use 30 GB of memory when there is only 8GB physical and only 662 MB swap space (that being "The space used on your startup drive by macOS memory management.").

That's my main question. But of course, any help on how to go about solving the problem is very much appreciated, too.
LVL 1
TuliTaivasserver adminAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

noxchoProduct ManagerCommented:
Did he or she ever close Safari? I would try quitting safari completely and then starting it again and checking how it behave after that.
See also if there are any addons in Safari.
serialbandCommented:
OS X can compress the memory used.  Safari is compressing 29.64 GB.  What website is the user visiting?  Maybe the user needs an ablocker.

I would recommend that you first reset the SMC and then reset the PRAM to clear any possible corruption of the SMC and NVRAM.  If that dosn't fix it, then back up the user's data and reinstall the OS without erasing the disk.  You can reinstall the OS to fix system.  It will reinstall all system files without deleting any software or user data, but it's always best to make a backup just in case.
Michael PainterIT administrator Small Business OwnerCommented:
Might want to scan that Mac with MalwareBytes for Mac.  It could be infected.
Not like Safari to use that much memory.
If you close all Safari processes with the Activity Monitor, does it free up the ram?
I would think that Mojave with no active apps running should be using less than 4GB ram.
TuliTaivasserver adminAuthor Commented:
Dear experts
Thank you for your comments. I can have a go on the Mac on wednesday and try what you suggested.
I have further information, though. The problem occurs on three of seven macs. I don't know what is different about the affected machines.
I'm pretty sure safari has been closed completely. At least when the upgrade from Sierra to Mojave was made.
I will report how it's going on thursday.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Browsers

From novice to tech pro — start learning today.