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

长时间使用会产生大内存对象 DeleteOnExitHook #2725

Closed
wwulfric opened this issue Sep 21, 2022 · 3 comments
Closed

长时间使用会产生大内存对象 DeleteOnExitHook #2725

wwulfric opened this issue Sep 21, 2022 · 3 comments
Labels
suggest Suggest

Comments

@wwulfric
Copy link

wwulfric commented Sep 21, 2022

建议先去看文档
快速开始常见问题
建议描述

FileUtil 使用的是 DefaultTempFileCreationStrategy

    public static void createPoiFilesDirectory() {
        File poiFilesPathFile = new File(poiFilesPath);
        createDirectory(poiFilesPathFile);
        TempFile.setTempFileCreationStrategy(new DefaultTempFileCreationStrategy(poiFilesPathFile));
        poiFilesPathFile.deleteOnExit();
    }

但是 DefaultTempFileCreationStrategy 的删除策略是 deleteOnExit,对于服务端程序来说,可能会造成java.io.DeleteOnExitHook 大对象,而且无法 GC 掉

image

TempFileCreationStrategy 的注释也表示:

DefaultTempFileCreationStrategy deletes temporary files when the JVM exits. This may not be suitable for long-running applications that never shut down the JVM since the list of registered files and disk space usage would grow for as long as the JVM is running. You may wish to implement your own strategy that meets the needs of your situation.

@wwulfric wwulfric added the suggest Suggest label Sep 21, 2022
@wwulfric
Copy link
Author

image

可以看出,每当执行Excel相关操作时,这里就会增加

@zhuangjiaju
Copy link
Collaborator

这个是个问题 已经在 3.1.2中修复

@wwulfric
Copy link
Author

wwulfric commented Jan 10, 2023

image
已经升级到3.1.3. 看起来似乎还是会增长
image

TempFile.setTempFileCreationStrategy(new DefaultTempFileCreationStrategy(poiFilesPathFile));之后,是不是有可能其他地方也会deleteOnExit

image

static这里还有,不清楚有没有关系

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

No branches or pull requests

2 participants