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

关于内存回收问题 #53

Closed
chenrj-u opened this issue Apr 17, 2024 · 8 comments
Closed

关于内存回收问题 #53

chenrj-u opened this issue Apr 17, 2024 · 8 comments

Comments

@chenrj-u
Copy link

如当前使用按分类初始化两个wordData,删除一个分类后如何把当前分类初始化的wordData占用的内存回收,是否可以暴露个清理方法?

@houbb
Copy link
Owner

houbb commented Apr 23, 2024

重新 init 可以满足需求吗?

@chenrj-u
Copy link
Author

当前使用方法是init了多个SensitiveWordBs,重新init无法满足需求

@houbb
Copy link
Owner

houbb commented Apr 24, 2024

这个具体的使用场景是什么?
andriod 使用中,首先初始化。然后动态调整希望删除掉对应的内存占用是吗?
如果移除的分类把对应的词库设置为空集合,然后其他功能全部关闭,可以满足不。

@houbb
Copy link
Owner

houbb commented Apr 24, 2024

第二个问题是其实不建议创建多个 SensitiveWordBs,统一使用一个,根据标签处理能否满足场景?

@chenrj-u
Copy link
Author

第二个问题是其实不建议创建多个 SensitiveWordBs,统一使用一个,根据标签处理能否满足场景?

我这边场景是不同模块需要不同的过滤逻辑,比如党建相关需要的敏感词就会多点,其他地方可能不要那么多过滤,看了下标签应该满足不了

@houbb
Copy link
Owner

houbb commented Apr 26, 2024

具体想要怎么样的回收机制?把词典构建占用的内存 map 销毁吗?

@chenrj-u
Copy link
Author

具体想要怎么样的回收机制?把词典构建占用的内存 map 销毁吗?

是的是的 就想要这个

@houbb
Copy link
Owner

houbb commented Apr 26, 2024

v0.16.1 已支持。

SensitiveWordBs wordBs = SensitiveWordBs.newInstance()
                .init();
// 后续因为一些原因移除了对应信息,希望释放内存。
wordBs.destroy();

@houbb houbb closed this as completed Apr 26, 2024
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