Out of Memory – Line 791 of WP-DB.php (mysql_real_escape_string)

If you suspect content-specific issue, I’d first try to start with clean site and set of test content instead ( official Theme Unit Test data for example).

If processing content is indeed at fault this is quite unusual issue. If you can narrow it down to specific function it might be possible to build some kind of test case, by getting content directly from database and running it through that function, while measuring resource consumption.