The application "XYZ" can't be opened! I am running macOS version 10.14.4 (18E226) on a MacBook Pro (13-inch, 2017, Two Thunderbolt 3 ports.)

Frequently, at least twice a week, I get this error while opening any application:


  The application "XYZ" can't be opened.


This happens with every application, even with default applications like Calculator! When this happens, no app will start. But, the already running applications continue to run. Even with Google Chrome, I can use the existing tabs but new tabs will not work.

I thought of attaching a screenshot, but the screenshot tool also didn't work.

Everything comes back to normal once I restart my mac.

This is so annoying and interrupts with my work. What could be the reason? How to fix this?

Edit:
Got the logs

May 12 20:26:40 MacBook-Pro com.apple.xpc.launchd[1] (com.apple.calculator.11368): Could not spawn trampoline /usr/libexec/xpcproxy: 35: Resource temporarily unavailable
May 12 20:26:40 MacBook-Pro com.apple.xpc.launchd[1] (com.apple.calculator.11368): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
May 12 20:26:40 MacBook-Pro com.apple.xpc.launchd[1] (com.apple.calculator.11368): Deferred spawn of service failed: 35: Resource temporarily unavailable


Since, screenshot tool didn't start, took a photo.
I faced the same problem here, and after investigating, I realized the problem was due to the number of processes my mac was running.

In my case, a cronjob was triggering multiple httpd threads (more than a hundred).

You can: 


open activity monitor and kill those processes; 
check your crontab -e and look for suspicious jobs