2017-07-28 136 views
0

似乎Alea的未處置類DeviceMemory2D正確Alea的犯規釋放內存正確

我檢查可用內存

let getFreeMemory() = 
    let free = Marshal.AllocHGlobal sizeof<uint64> 
    let total = Marshal.AllocHGlobal sizeof<uint64> 

    let freePtr = NativeInterop.NativePtr.ofNativeInt<nativeint> free 
    let totalPtr = NativeInterop.NativePtr.ofNativeInt<nativeint> total 

    CUDAInterop.cuMemGetInfo(freePtr, totalPtr) 
    |> cuSafeCall 

    let result = NativeInterop.NativePtr.get freePtr 0 

    Marshal.FreeHGlobal free 
    Marshal.FreeHGlobal total 

    uint64 result 

這裏的代碼是,檢查是否有任何泄漏

Seq.init 100 (fun _ -> 
     use arr = Gpu.Default.AllocateDevice<float>(1000,1000) 

     getFreeMemory() 
     |> printfn "%d" 
    ) 
|> Seq.iter id 
代碼

The outputs

從輸出圖像t他記憶似乎並沒有被安置

回答