diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 6589518..8076fec 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.0-rc1","generation_timestamp":"2023-11-06T17:03:27","documenter_version":"1.1.2"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.0-rc1","generation_timestamp":"2023-11-06T17:17:07","documenter_version":"1.1.2"}} \ No newline at end of file diff --git a/dev/api/index.html b/dev/api/index.html index 23cbb86..dcf61b6 100644 --- a/dev/api/index.html +++ b/dev/api/index.html @@ -6,4 +6,4 @@ foo (generic function with 1 method) julia> allocs = check_allocs(foo, (Int, Int)) -AllocCheck.AllocInstance[]source +AllocCheck.AllocInstance[]source diff --git a/dev/index.html b/dev/index.html index 7130aa2..32c1d3b 100644 --- a/dev/index.html +++ b/dev/index.html @@ -5,7 +5,7 @@ check_allocs(mymod, (Float64,))
AllocCheck.AllocInstance[]

This returned an empty array, indicating that the function was proven to not allocate any memory 🎉

When used on a function that may allocate memory

linsolve(a, b) = a \ b
 
 allocs = check_allocs(linsolve, (Matrix{Float64}, Vector{Float64}));
-length(allocs)
55

we get a non-empty array of allocation instances. Each allocation instance contains some useful information, for example

allocs[1]
Allocation of Vector{Float64} in ./boot.jl:475
+length(allocs)
55

we get a non-empty array of allocation instances. Each allocation instance contains some useful information, for example

allocs[1]
Allocation of Vector{Float64} in ./boot.jl:475
   | Array{T,1}(::UndefInitializer, m::Int) where {T} =
 
 Stacktrace:
@@ -21,4 +21,4 @@
    @ LinearAlgebra /opt/hostedtoolcache/julia/1.10.0-rc1/x64/share/julia/stdlib/v1.10/LinearAlgebra/src/generic.jl:1118
  [6] linsolve(a::Matrix{Float64}, b::Vector{Float64})
    @ Main ./index.md:21
-

we see what type of object was allocated, and where in the code the allocation appeared.

Functions that throw exceptions

Some functions that we do not expect may allocate memory, like sin, actually may:

length(check_allocs(sin, (Float64,)))
0

The reason for this is that sin may throw an error, and the exception object requires some allocations. We can ignore allocations that only happen when throwing errors by passing ignore_throw=true:

length(check_allocs(sin, (Float64,); ignore_throw=true)) # ignore allocations that only happen when throwing errors
0

Limitations

  1. Runtime dispatch

Any runtime dispatch is conservatively assumed to allocate.

+

we see what type of object was allocated, and where in the code the allocation appeared.

Functions that throw exceptions

Some functions that we do not expect may allocate memory, like sin, actually may:

length(check_allocs(sin, (Float64,)))
0

The reason for this is that sin may throw an error, and the exception object requires some allocations. We can ignore allocations that only happen when throwing errors by passing ignore_throw=true:

length(check_allocs(sin, (Float64,); ignore_throw=true)) # ignore allocations that only happen when throwing errors
0

Limitations

  1. Runtime dispatch

Any runtime dispatch is conservatively assumed to allocate.