[poppler] Properly using(and freeing) PopplerPage objects
Reza Hasanzadeh
rz.hasanzade at gmail.com
Mon Dec 9 11:20:54 UTC 2019
Hey there,
I have got a few questions about memory bhaviour of Poppler objects:
- I hold a list of all PopplerPage objects of a document in
memory(obtained with "poppler_document_get_page"). I noticed my
program consumes 10x memory amount compared to Evince fed the same
file. Are there any best practices for dealing with PopplerPage
objects?
- What is the proper way of freeing PopplerDocument? since I retain a
single PopplerDocument object will "g_object_unref(doc)" suffice?
- How should I free a PopplerPage obtained with
"poppler_document_get_page"? I currently "use g_object_unref" and I
doubt if it is enough since in Poppler's source code when I ask a
PopplerPage object it seems that each returned page refs the document
that the page belongs to:
PopplerPage *
_poppler_page_new (PopplerDocument *document, Page *page, int index)
{
PopplerPage *poppler_page;
g_return_val_if_fail (POPPLER_IS_DOCUMENT (document), NULL);
poppler_page = (PopplerPage *) g_object_new (POPPLER_TYPE_PAGE,
nullptr, NULL);
poppler_page->document = (PopplerDocument *) g_object_ref (document);
poppler_page->page = page;
poppler_page->index = index;
return poppler_page;
}
I am developing a book reading system.
Reza
More information about the poppler
mailing list