diff --git a/src/array.jl b/src/array.jl index b38895c062..f6af831943 100644 --- a/src/array.jl +++ b/src/array.jl @@ -72,12 +72,12 @@ mutable struct CuArray{T,N,M} <: AbstractGPUArray{T,N} maxsize end - GPUArrays.cached_alloc((CuArray, CUDA.device(), T, bufsize, M)) do - data = DataRef(pool_free, pool_alloc(M, bufsize)) - obj = new{T,N,M}(data, maxsize, 0, dims) - finalizer(unsafe_free!, obj) - return obj - end::CuArray{T, N, M} + data = GPUArrays.cached_alloc((CuArray, device(), M, bufsize)) do + DataRef(pool_free, pool_alloc(M, bufsize)) + end + obj = new{T,N,M}(data, maxsize, 0, dims) + finalizer(unsafe_free!, obj) + return obj end function CuArray{T,N}(data::DataRef{Managed{M}}, dims::Dims{N}; @@ -85,6 +85,7 @@ mutable struct CuArray{T,N,M} <: AbstractGPUArray{T,N} check_eltype(T) obj = new{T,N,M}(data, maxsize, offset, dims) finalizer(unsafe_free!, obj) + return obj end end diff --git a/src/memory.jl b/src/memory.jl index b2910a0a58..5b8d866cc8 100644 --- a/src/memory.jl +++ b/src/memory.jl @@ -516,6 +516,8 @@ mutable struct Managed{M} end end +Base.sizeof(managed::Managed) = sizeof(managed.mem) + # wait for the current owner of memory to finish processing function synchronize(managed::Managed) synchronize(managed.stream)