alist-org / alist

🗂️A file list/WebDAV program that supports multiple storages, powered by Gin and Solidjs. / 一个支持多存储的文件列表/WebDAV程序,使用 Gin 和 Solidjs。
https://alist.nn.ci
GNU Affero General Public License v3.0
39.3k stars 5.1k forks source link

当从local存储copy大文件至其他Alistv3存储时,内存暴增甚至会导致crash #6613

Closed TookeX closed 1 week ago

TookeX commented 2 weeks ago

Please make sure of the following things

AList Version / AList 版本

v3.35.0

Driver used / 使用的存储驱动

Local & Alist v3

Describe the bug / 问题描述

同局域网下多个不同类型的设备部署了Alist,当尝试从local copy一些大文件去到远端的alist v3的时候,会观察到alist内存占用暴增,甚至超过正在拷贝的文件大小的增幅。在一些内存较小的设备上会导致进程crash,进而copy失败。为提issue在台式机上windows平台的alist做演示,目标端为android的alist_flutter。同时验证过crash会出现在以android的alist和docker的alist等内存较小的设备上作为源端向远端alist v3的storage copy时会crash。

Reproduction / 复现链接

https://alist.nn.ci/zh/guide/api/fs.html#post-%E5%A4%8D%E5%88%B6%E6%96%87%E4%BB%B6

Config / 配置

image

Logs / 日志

image image

welcome[bot] commented 2 weeks ago

Thanks for opening your first issue here! Be sure to follow the issue template!

j2rong4cn commented 2 weeks ago

问题出现在Alist v3驱动,用的 https://github.com/go-resty/resty 这个库实现的上传 一番debug后定位到go-resty/resty/middleware.go#L490 go-resty/resty这个库为了支持重试会缓存io.Reader类型,执行go-resty/resty/middleware.go#L490之后内存就会暴增 想了2种解决方法

我试了第1个方法,内存不会暴增 @xhofe 有更好的解决方法吗?