How to make sure KDE has enough memory, and computer not freeze?

I also use a Windows laptop for work. A few days ago when I was working in IntelliJ IDEA (I had 3 instances of it open). I got a warning (from IntelliJ) that IntelliJ had problems working because of low memory (although Windows worked fine).

There should be reserved a minimum amount of memory for KDE to function properly. No application should be allowed to consume so much memory that X, Window Manager or KDE cannot function and freezes.