[wp-hackers] Running out of memory using $wpdb
Tom Barrett
tcbarrett at gmail.com
Wed Mar 28 14:34:59 UTC 2012
Just a quick update..
On 21 March 2012 15:43, Beau Lebens <beau at dentedreality.com.au> wrote:
> I think this line was supposed to be a method call:
>
> > $wpdb->flush;
>
> Are you sure it's not running out of time?
>
No, definitely memory.
> If you're doing regular expression parsing of some sort on your data
> then there are small, inherent internal caches that cannot be cleared,
> so there's no way that I know of to regain the memory that bleeds out
> through that, other than ending the request and doing another (AJAX,
> auto-redirect, something along those lines).
>
Initially, I was doing nothing. Just grabbing rows of data. I hadn't got so
far as to parse any rows.
> You can also change your main loop to:
>
> while ( $result = $wpdb->get_results( "SELECT * FROM $table WHERE
> status='LIVE' LIMIT $start, $count" ) ) {
>
This proved to be the only thing to have any noticeable improvement on
memory usage. At this point I managed to grab all the rows I needed. I then
broke it down into subsets (on the joined table) that I could serialise and
then re-iterate.
Thanks.
--
http://www.tcbarrett.com | http://gplus.to/tcbarrett |
http://twitter.com/tcbarrett
More information about the wp-hackers
mailing list