naihe2010/apvlv — pull request #12 by DarkStarSword (2012-10-15 01:30:30+00:00)
Title: Fix a few more memory leaks in ApvlvPDF

I was still seeing apvlv leak memory while scrolling through pdf
documents, which valgrind pointed to apvlv::ApvlvPDF::render as the
main culprit.

I've gone through the ApvlvPdf class and added a g_object_unref for
every occurance of poppler_document_get_page, as well as freeing another
list in ApvlvPDF::getlinks.

Testcase:
1. Configure apvlv with cmake -D CMAKE_BUILD_TYPE=DEBUG
2. Optionally start htop in another window to observe the memory blowout
3. valgrind --error-limit=no --leak-check=full apvlv very_large_document.pdf
4. Continually press page down to scroll through the document
5. Close apvlv and read valgrind summary

Before (note over 100M are marked as possibly lost):
==18333== LEAK SUMMARY:
==18333== definitely lost: 4,416 bytes in 8 blocks
==18333== indirectly lost: 11,392 bytes in 354 blocks
==18333== possibly lost: 135,511,892 bytes in 1,029,946 blocks
==18333== still reachable: 8,670,227 bytes in 37,143 blocks

After (Down to under 10MB marked as possibly lost):
==22504== LEAK SUMMARY:
==22504== definitely lost: 4,416 bytes in 8 blocks
==22504== indirectly lost: 11,392 bytes in 354 blocks
==22504== possibly lost: 9,305,771 bytes in 25,887 blocks
==22504== still reachable: 3,286,064 bytes in 11,783 blocks

Signed-off-by: Ian Munsie