system_cron() eats all ram and runs forever Client doesn't ran Cron for >6 months. So in database, we had large tables. I have cleared  tables accesslog, cache_*, watchdog, flood manually in MySQL.

After that, running Cron runs forever. Especially system_cron(). What part of that function can cause this? It seems that probably mysql is eating RAM, but I'm not sure.

system_cron() touches following tables - cache_* (empty), flood(empty), batch(1 row), queue(159 rows), file_managed(18,163 rows).

Maybe something is wrong with file_managed?
Try Elysia Cron, it provides a lot of fine tuning and control over standard cron.

Khalid Bahey from 2bits.com wrote an extensive article regarding this module: Improving the performance of Drupal's cron by using the Elysia cron module