Lxml memory leak with Python3 in Ubuntu12.04

I just installed lxml using easy_install on a Ubuntu12.04 machine with Python 3.2.3 installed. lxml is the latest version of 3.0Alpha.

I tried the following code:

 import lxml.html def proc_tweet(ss): html=lxml.html.fragment_fromstring(ss) ps=html.xpath("//p[@node-type='feed_list_content']") def test(): ss='' f=open('test') for l in f: ss+=l.strip() f.close() while True: proc_tweet(ss) if __name__=='__main__': test() 

Here "test" is a file containing a short piece of HTML:

 <dl action-type="feed_list_item" mid="3409553360609821" class="feed_list W_linecolor"> <dd class="content"> <p node-type="feed_list_content">This is a drill.</p> </dd> <dd class="clear"></dd> </dl> 

Problem: lxml eats all my memory from time to time. I tried this

 del ps del html 

This does not work. Does anyone know why?

+4
source share
1 answer

This is a bug fixed in version 3.0 beta 1.

For future reference, it is always better to report a problem with a software tool directly to a project that supports it, rather than just posting it in an arbitrary place on the Internet. Tracking launcher errors is the right place to report lxml errors. The github tracker is mainly used only for pull requests.

+1
source

Source: https://habr.com/ru/post/1433724/


All Articles