What happen today is that I spend at least 6 hours searching for a problem in the mysqli package of php. Found out that there is a bug in the component itself. What actually happen is that when you are using the mysqli in an application that do not have in its database longtext or blob columns in any of the tables you will never have a problem. Once you try reading from a table that have longtext column you will see an error for trying allocating a lot of memory.
I really spend a lot of time, because in the project which i was doing the change this is a core part. I knew that the database layer we had there was reliable and bug free. So most of my attention was not digging in the mysqli part.
Finally I found this bug here: https://bugs.php.net/bug.php?id=51386 and changed some stuff in our library and BOOM everything start working without any problem.
What is the conclusion: