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

内存泄漏 #28

Open
OnlyChenDaDa opened this issue May 25, 2022 · 1 comment
Open

内存泄漏 #28

OnlyChenDaDa opened this issue May 25, 2022 · 1 comment

Comments

@OnlyChenDaDa
Copy link

Subscriber类中的take方法被interrupt异常拦截时需要再标记下interrupt,否则线程无法正常结束导致越来越多,最终结果就可能内存溢出
protected byte[] take()
{
byte[] data = null;
try
{
synchronized (lock)
{
while (messages.isEmpty())
{
lock.wait(100);
if (this.isInterrupted()) return null;
}
data = messages.removeFirst();
}
return data;
}
catch(Exception ex)
{
this.interrupt(); //需加入
return null;
}
}

@glaciall
Copy link
Owner

好的,非常感谢。

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

2 participants