Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mpp_dec_parser 和mpp_dec_hal 无法释放,导致内存泄漏 #623

Open
HouLingLXH opened this issue Jun 24, 2024 · 0 comments
Open

mpp_dec_parser 和mpp_dec_hal 无法释放,导致内存泄漏 #623

HouLingLXH opened this issue Jun 24, 2024 · 0 comments

Comments

@HouLingLXH
Copy link

一下是我的初始化和释放代码:
`
MppDecoder::~MppDecoder() {
std::cout << "====析构==MppDecoder=" << std::endl;
if (loop_data.packet) {
mpp_packet_deinit(&loop_data.packet);
loop_data.packet = NULL;
}
if (frame) {
mpp_frame_deinit(&frame);
frame = NULL;
}
if (mpp_ctx) {
mpp_destroy(mpp_ctx);
mpp_ctx = NULL;
}

if (loop_data.frm_grp) {
    mpp_buffer_group_put(loop_data.frm_grp);
    loop_data.frm_grp = NULL;
}

}

int MppDecoder::Init(int video_type, int fps, void* userdata)
{
std::thread::id this_thread_id = std::this_thread::get_id(); // 获取本线程的ID
std::cout << " MppDecoder::Init Thread ID = " << this_thread_id << std::endl;

MPP_RET ret         = MPP_OK;
this->userdata = userdata;
this->fps = fps;
this->last_frame_time_ms = 0;
if(video_type == 264) {
    mpp_type  = MPP_VIDEO_CodingAVC;
} else if (video_type == 265) {
    mpp_type  =MPP_VIDEO_CodingHEVC;
} else {
    LOGD("unsupport video_type %d", video_type);
    return -1;
}
LOGD("mpi_dec_test start ");
memset(&loop_data, 0, sizeof(loop_data));
LOGD("mpi_dec_test decoder test start mpp_type %d ", mpp_type);

MppDecCfg cfg       = NULL;

MppCtx mpp_ctx          = NULL;
ret = mpp_create(&mpp_ctx, &mpp_mpi);
if (MPP_OK != ret) {
    LOGD("mpp_create failed ");
    return 0;
}

ret = mpp_init(mpp_ctx, MPP_CTX_DEC, mpp_type);
if (ret) {
    LOGD("%p mpp_init failed ", mpp_ctx);
    return -1;
}

mpp_dec_cfg_init(&cfg);

/* get default config from decoder context */
ret = mpp_mpi->control(mpp_ctx, MPP_DEC_GET_CFG, cfg);
if (ret) {
    LOGD("%p failed to get decoder cfg ret %d ", mpp_ctx, ret);
    return -1;
}

/*
 * split_parse is to enable mpp internal frame spliter when the input
 * packet is not aplited into frames.
 */
ret = mpp_dec_cfg_set_u32(cfg, "base:split_parse", need_split);
if (ret) {
    LOGD("%p failed to set split_parse ret %d ", mpp_ctx, ret);
    return -1;
}

ret = mpp_mpi->control(mpp_ctx, MPP_DEC_SET_CFG, cfg);
if (ret) {
    LOGD("%p failed to set cfg %p ret %d ", mpp_ctx, cfg, ret);
    return -1;
}

mpp_dec_cfg_deinit(cfg);

loop_data.ctx            = mpp_ctx;
loop_data.mpi            = mpp_mpi;
loop_data.eos            = 0;
loop_data.packet_size    = packet_size;
loop_data.frame          = 0;
loop_data.frame_count    = 0;
return 1;

}`

析构之后,我在htop中查看,发现依然有很多mpp_dec_parser 和mpp_dec_hal 无法释放, 随着我多次反复创建于析构,他们会越来越多,内存也在不断被占用, 应该怎么办?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant