A fix for wordpress and “Fatal error: Allowed memory size”

It happened me twice and maybe it happened to you (hence this post): i would install a plugin (like Relevanssi or Search Unleashed), which would break Wordpress or not function like i want it, desactivate it, at which point Wordpress goes berseck.
everytime i would edit or add a post or page, i would get this error message.

PHP:
  1. Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 587403 bytes) in /wp-includes/wp-db.php

The best solution i 've had so far is to increase php memory limit to a high value. Not clean, i know, but it works.
So as not to destroy the fix whenever you upgrade Wordpress, put it in your wp-config.php file.

PHP:
  1. ini_set("memory_limit","365M");