After a site move (from one webhosting to another) the site reported error 500 internal server error. When checking the logfile the file libraries/joomla/error/exception.php reported that allowed memor size was exhausted. I tried increasing it by adjusting the php.ini settings all the way up to 2 GB without resolving the problem. This is way more than Joomla should need.
The problem was that I had forgot to update the temp and log paths in Global settings to the ones on the new server. The path the site is running under can be found by the menu Help -> System info. Then I adjusted temp path and log path in Global settings and the problem was resolved.
If your site gives you error 500 internal server error, access your Joomla database using for example phpMyAdmin and delete all rows in the jos_session table.
Another solution if the problem is a corrupted database is to repair the database tables using phpMyAdmin.
In configuration.php, also try setting cache_handler=”file” instead of “memcache”.