napoler / solr-php-client

Automatically exported from code.google.com/p/solr-php-client
Other
0 stars 0 forks source link

memory leak on massive indexation #60

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
the _sendRawPost method adds the whole documents to be indexed to the content 
key of the stream_context_set_option call.

This key seems to be incremental. If you have a loop adding many documents, the 
memory will leak.

To avoid that issue you can add :
stream_context_set_option($this->_postContext, array(
    'http' => array(
        'content' => '',
    )
));
Before the return $response;
At the end of the _sendRawPost method.

Original issue reported on code.google.com by nicolas....@gmail.com on 4 Feb 2011 at 11:03

GoogleCodeExporter commented 9 years ago
What version of the client are you using, this may already be fixed.

see issue #20, this should be fixed in r22 and above (started reusing the same 
stream context)

If this isn't the same bug and isn't fixed by a newer version, then it may be a 
regression and I'd appreciate if you could followup with more information. 
Thanks.

Original comment by donovan....@gmail.com on 4 Feb 2011 at 2:46

GoogleCodeExporter commented 9 years ago
I'm using the r22 version, and the memory leaks each time you call the 
addDocuments method.

Using the same stream context doesn't seem to fix PHP leaking the memory usage 
each time the stream context is used.

Original comment by nicolas....@gmail.com on 4 Feb 2011 at 3:48

GoogleCodeExporter commented 9 years ago
Are you using a single client instance for all indexing operations, or are you 
creating a lot of instances? If you're using a single instance, you should see 
your memory stay rather constant. If you're creating a lot of instances then 
the stream contexts will accumulate - since php never gets rid of them. 

If you're creating lots of instances, then even if the post body is cleared 
each time, you'd still have a leakage problem, just to a lesser degree.

Original comment by donovan....@gmail.com on 4 Feb 2011 at 4:12

GoogleCodeExporter commented 9 years ago
Current implementation of file get contents based http transport does already 
clear the post body after the request:

http://code.google.com/p/solr-php-client/source/browse/branches/http_requests/Ap
ache/Solr/HttpTransport/FileGetContents.php?r=53#168

Perhaps you could consider upgrading from r22 to HEAD (r53 currently)

Original comment by donovan....@gmail.com on 4 Feb 2011 at 4:25

GoogleCodeExporter commented 9 years ago
I'm using only one instance of the client and the leak is pretty clear (around 
4Mb after each call to addDocuments).

I could go for the last revision, you are right.

My PHP version is 5.2.6 (debian lenny - maybe that is the reason), but i'd 
advise anyone who won't/can't take the chance to upgrade to the last revision 
to try the fix i gave.
It really makes the deal for me.

Original comment by nicolas....@gmail.com on 5 Feb 2011 at 7:07

GoogleCodeExporter commented 9 years ago
this problem was already fixed in source, but there was no more current 
download than r22 at the time. Now there is the r60 download, so I'm going to 
close this.

Original comment by donovan....@gmail.com on 20 May 2011 at 12:13