Chris January wrote:
I tried both methods, but PHP runs out of memory in both cases.
I've made some tests and I think we can do nothing about this. The problem is not in preg_split, the problem is in PHP's arrays handling. Array with 150k items requires 20-30 MB of memory. Also at x86_64 the footprint is 25% bigger.
Simple test, an array with empty items:
$b = array_fill(0, 100000, NULL);
in-memory size for this array = 10MB!!!
So, if you're working with such big mailboxes, you'll need to increase memory_limit.