# Problem with libxml and Reader#expand not freeing memory

**URL:** <https://www.ruby-forum.com/t/problem-with-libxml-and-reader-expand-not-freeing-memory/170743>\
**Category:** Ruby\
**Created:** [June 22, 2009, 11:34am UTC](https://www.ruby-forum.com/t/problem-with-libxml-and-reader-expand-not-freeing-memory/170743 "2009-06-22T11:34:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [June 22, 2009, 11:34am UTC](https://www.ruby-forum.com/t/problem-with-libxml-and-reader-expand-not-freeing-memory/170743/1 "2009-06-22T11:34:56Z")

</div>

Hi,

I’ve already posted it to libxml-ruby tracker page, but I guess this  
list is read by more people 🙂

I’m trying to use libxml-ruby to parse ~250MB XML files. The files  
contain list of similar elements, so I’m iterating  
over each element and expand it with reader.expand:

reader.read # go to the first node  
begin  
node = reader.expand  
import\_data\_to\_db(node)  
GC.start  
end while reader.next != 0

The problem is that the memory allocated by objects created using  
reader.expand is not freed till the reader is closed, which is  
actually equivalent to parsing the whole file in memory, which  
contradicts the whole idea of using pull parser.

Anyone had similar issue?
