Metadata tags leak memory

Bug #581787 reported by Olivier Tilloy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pyexiv2
Fix Released
High
Olivier Tilloy

Bug Description

The attached script highlights the issue. Run it and monitor the memory usage: it steadily increases and is never re-claimed.

Revision history for this message
Olivier Tilloy (osomon) wrote :

A call to ImageMetadata.write() is not needed for the leak to be observed, I updated the test case accordingly.

Olivier Tilloy (osomon)
summary: - Writing new metadata leaks memory
+ Metadata tags leak memory
Revision history for this message
Olivier Tilloy (osomon) wrote :

There are in fact two types of leak that can be observed here:

1) The memory allocated when instantiating an {Exif,Iptc,Xmp}Tag without a value is not freed, it can be observed with the following piece of code:

    for i in xrange(1000000):
        tag = pyexiv2.ExifTag('Exif.Image.Artist')
        # - or -
        tag = pyexiv2.IptcTag('Iptc.Application2.Subject')
        # - or -
        tag = pyexiv2.XmpTag('Xmp.dc.subject')

2) When setting the values of an IptcTag, a copy is performed but the memory allocated is never freed, it can be observed with the following piece of code:

    values = ['bla'] * 10000
    for i in xrange(1000000):
        tag = pyexiv2.IptcTag('Iptc.Application2.Subject')
        tag.values = values

Changed in pyexiv2:
assignee: nobody → Olivier Tilloy (osomon)
status: Confirmed → In Progress
Revision history for this message
Olivier Tilloy (osomon) wrote :

The first type of leak is already fixed in the branch linked.

Revision history for this message
Olivier Tilloy (osomon) wrote :

After more tests, it appears that the second type is in fact not a leak. The very large size of the test values was to blame, and although the memory consumption went quite high (~130MB), it then remained stable. Testing with a smaller list of values (e.g. 100 elements, which is already quite large for real-world use cases) shows a small and constant memory footprint.

Olivier Tilloy (osomon)
Changed in pyexiv2:
status: In Progress → Fix Committed
Olivier Tilloy (osomon)
Changed in pyexiv2:
milestone: none → 0.2.2
Olivier Tilloy (osomon)
Changed in pyexiv2:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.