Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

[BUG] Memory accumulation when using load_image in a loop

未關閉
#365 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
30/100
Issue 類型
缺陷
描述清晰度
需要釐清
活躍度
停滯
技術堆疊
rust

研究方向

首先執行 src/main.rs:6 中提供的迴圈,並檢查 src/image/mod.rs:317 中的 load_image wrapper,以及回報的原生 af_load_image 路徑。追蹤重複載入影像是否會保留裝置記憶體,並確認相關的清理或所有權行為。完成的標準是:重現過程不再持續累積記憶體直到發生記憶體不足錯誤,並且有一個針對重複載入的回歸測試。

由索引模型根據 Issue 內容生成。

描述

Bug

The following program crashed. But why?

use arrayfire::*;

fn main() {
    let mut y =constant!(0 as u8;1);
    for i in 0..1000 {
        let x = load_image::<u8>("2dzs/robot_2dz.png".to_string(), true);
        let z = or(&x, &y, true);
        y = z.copy();
        println!("i={}", i);
    }
    println!("max(y)={:#?}", max_all(&y));
}

i=0
i=1
i=2
i=3
i=4
i=5
i=6
i=7
i=8
i=9
i=10
i=11
i=12
i=13
i=14
i=15
i=16
i=17
i=18
i=19
i=20
i=21
i=22
i=23
i=24
i=25
i=26
i=27
i=28
i=29
i=30
i=31
i=32
i=33
i=34
i=35
i=36
i=37
i=38
i=39
i=40
i=41
i=42
i=43
i=44
i=45
i=46
i=47
i=48
i=49
i=50
i=51
thread 'main' panicked at 'Error message: System or Device ran out of memory
Last error: In function af_load_image
In file src/api/c/imageio.cpp:393


 0# 0x00007F4FC1A299AF in /opt/arrayfire/lib/libafcuda.so.3
 1# 0x0000560F6F590AFF in target/debug/crash
 2# 0x0000560F6F590099 in target/debug/crash
 3# 0x0000560F6F5903AB in target/debug/crash
 4# 0x0000560F6F59031E in target/debug/crash
 5# 0x0000560F6F58FC41 in target/debug/crash
 6# 0x0000560F6F5A707F in target/debug/crash
 7# 0x0000560F6F58FC10 in target/debug/crash
 8# 0x0000560F6F5902EC in target/debug/crash
 9# 0x00007F4FFB823510 in /lib/x86_64-linux-gnu/libc.so.6
10# __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
11# 0x0000560F6F58FB15 in target/debug/crash
', /home/joe/.cargo/registry/src/mirrors.ustc.edu.cn-12df342d903acd47/arrayfire-3.8.0/src/core/error.rs:37:14
stack backtrace:
   0: rust_begin_unwind
             at /rustc/c07a8b4e09f356c7468b69c50cac7fc5b5000b8a/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/c07a8b4e09f356c7468b69c50cac7fc5b5000b8a/library/core/src/panicking.rs:142:14
   2: arrayfire::core::error::handle_error_general
             at /home/joe/.cargo/registry/src/mirrors.ustc.edu.cn-12df342d903acd47/arrayfire-3.8.0/src/core/error.rs:37:14
   3: arrayfire::core::error::Callback::call
             at /home/joe/.cargo/registry/src/mirrors.ustc.edu.cn-12df342d903acd47/arrayfire-3.8.0/src/core/error.rs:29:9
   4: arrayfire::core::error::HANDLE_ERROR
             at /home/joe/.cargo/registry/src/mirrors.ustc.edu.cn-12df342d903acd47/arrayfire-3.8.0/src/core/error.rs:95:5
   5: arrayfire::image::load_image
             at /home/joe/.cargo/registry/src/mirrors.ustc.edu.cn-12df342d903acd47/arrayfire-3.8.0/src/image/mod.rs:317:9
   6: crash::main
             at ./src/main.rs:6:17
   7: core::ops::function::FnOnce::call_once
             at /rustc/c07a8b4e09f356c7468b69c50cac7fc5b5000b8a/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
主要語言
Rust
星號
827
分支
59
PR 合併指標
30 天內沒有已合併 PR

貢獻指南

這個儲存庫沒有索引到貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

arrayfire/arrayfire-rust 的其他 Issue

查看 arrayfire/arrayfire-rust 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。