poppler-cpp memory leaking on Windows for some pdf
Env
OS: Windows 10 IDE: Visual Studio 2019 poppler: 20.11.0 x64 msvc
Problem
Memory leak for some pdf when calling poppler::page_renderer::render
Reproduce
-
Download the pdf
http://www.cninfo.com.cn/new/disclosure/detail?plate=szse&orgId=gssz0000672&stockCode=000672&announcementId=1207498718&announcementTime=2020-04-15
Click the blue button on the top right -
In a Visual Studio solution, include
test.h
and call the function
test.h
#pragma once
#include <iostream>
#include <poppler-document.h>
#include "poppler-page.h"
#include "poppler-page-renderer.h"
std::string pdf_file_path(u8"上峰水泥:2019年年度报告.PDF")
void test_poppler_memory_leak()
{
if (!poppler::page_renderer::can_render())
{
std::cerr << "can not render" << std::endl;
return;
}
poppler::document * p_doc = poppler::document::load_from_file(pdf_file_path);
int page_index = 85;
poppler::page * p_page = p_doc->create_page(page_index);
poppler::page_renderer page_render;
poppler::image poppler_img = page_render.render_page(p_page, 120, 120); // it leaks
delete p_page;
delete p_doc;
}
- Leak message sample in Visual Studio 2019
{35684} normal block at 0x000001EA57F0CA40, 32 bytes long.
Data: <C:\Windows\Fonts> 43 3A 5C 57 69 6E 64 6F 77 73 5C 46 6F 6E 74 73
{35683} normal block at 0x000001EA57EDDC80, 16 bytes long.
Data: <p4 W > 70 34 EB 57 EA 01 00 00 00 00 00 00 00 00 00 00
{35682} normal block at 0x000001EA57EB3470, 40 bytes long.
Data: < W @ W > 80 DC ED 57 EA 01 00 00 40 CA F0 57 EA 01 00 00
{35681} normal block at 0x000001EA57F0C560, 32 bytes long.
Data: <Courier-BoldObli> 43 6F 75 72 69 65 72 2D 42 6F 6C 64 4F 62 6C 69
{35680} normal block at 0x000001EA57EDDD20, 16 bytes long.
Data: < 5 W > C0 35 EB 57 EA 01 00 00 00 00 00 00 00 00 00 00
More Info
With many other pdf files, it doesn't leak, even include Chinese fonts. It seems that some fonts lead to memory leaks.