gpt4 book ai didi

java - OutOfMemoryError - 通过 weblogic 服务器

转载 作者:行者123 更新时间:2023-12-02 09:49:55 24 4
gpt4 key购买 nike

如何解决 weblogic 服务器中的 OutOfMemoryError

增加堆大小 - -Xmx10G、-Xms10G实现了 SFTP 而不是 FTP

byte[] fileArr = null; ByteArrayOutputStream 输出;

    StringBuilder strBuild = new StringBuilder();

strBuild.append(path);

strBuild.append(fileName);
InputStream inputStr = null;

BufferedInputStream bis = null;

ByteBuffer buffer = null;

ReadableByteChannel inputChannel = null;
WritableByteChannel outputChannel = null;


try {

inputStr = this.sftpClient.getInputStream(strBuild.toString());

if(READ_BUFFER_SIZE <= 0){

buffer = ByteBuffer.allocateDirect(DEFAULT_BUFFER_SIZE);
}

else{
buffer = ByteBuffer.allocateDirect(READ_BUFFER_SIZE);

}

bis = new BufferedInputStream(inputStr);

out = new ByteArrayOutputStream();

inputChannel = Channels.newChannel(bis);

outputChannel = Channels.newChannel(out);

while (inputChannel.read(buffer) > 0) {
buffer.flip();

outputChannel.write(buffer);

buffer.compact();
}

需要输入文件的 ByteArray 中的响应

最佳答案

在您的代码中,我没有看到您在哪里关闭了流。可能服务器会保留您打开的缓冲区。

插入 try-with-resource ( https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html ) 或关闭代码中的流

关于java - OutOfMemoryError - 通过 weblogic 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56392450/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com