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

程序退出时内存泄漏 #45

Closed
crackgame opened this issue Jul 28, 2016 · 4 comments
Closed

程序退出时内存泄漏 #45

crackgame opened this issue Jul 28, 2016 · 4 comments

Comments

@crackgame
Copy link

程序退出时,_freeLogDatas 没有正确释放掉

@crackgame crackgame changed the title 程序退出是内存泄漏 程序退出时内存泄漏 Jul 28, 2016
@crackgame
Copy link
Author

我这样改了,不确定是否正确

bool LogerManager::stop()
{
if (_runing)
{
showColorText("log4z stopping \r\n", LOG_LEVEL_FATAL);
_runing = false;
wait();

    while(!_freeLogDatas.empty()) {
        delete _freeLogDatas.back();
        _freeLogDatas.pop_back();
    }

    return true;
}
return false;

}

@zsummer
Copy link
Owner

zsummer commented Jul 28, 2016

内存会被系统回收, 并且freelist中的用以重用的驻留内存块数不超过200个, 做这些事情是多余的.

@acrobatman
Copy link

你好,你这个可重用的驻留内存块使用前提是进程不退出的情况下吧,如果对于服务端多进程模式,每笔业务开启一个进程,业务完成进程退出(正常或者异常),这种情况下驻留内存能保证不增长吗?抱歉,我还没有看代码

@zsummer
Copy link
Owner

zsummer commented Aug 21, 2016

这里驻留内存的意思是 在进程的生命周期内这些内存不会释放, 进程退出后 所有内存内存都会被系统回收掉.
只要不是共享内存这种跨进程生命周期的特殊内存分配, 在进程退出后 所有该进程分配的内存都会被操作系统回收掉, 这个是操作系统的基础知识. 详细的资料可以随便搜索下关键字 操作系统 内存管理就可以获取到.

@zsummer zsummer closed this as completed Nov 6, 2016
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

3 participants