Skip to content

@allocated and @allocations are giving the wrong result. #56705

@sadish-d

Description

@sadish-d
julia> @time Int[]
  0.000002 seconds (1 allocation: 64 bytes)
Int64[]

julia> @allocated Int[]
0

julia> @allocations Int[]
0

julia> @time Array{Int}(undef)
  0.000003 seconds (1 allocation: 64 bytes)
0-dimensional Array{Int64, 0}:
0

julia> @allocated Array{Int}(undef)
0

julia> @allocations Array{Int}(undef)
0

julia> @time println("")

  0.000194 seconds (8 allocations: 160 bytes)

julia> @allocated println("")

160

julia> @allocations println("")

8

versioninfo

julia> versioninfo()
Julia Version 1.10.3
Commit 0b4590a5507 (2024-04-30 10:59 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 8 × Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)
Environment:
  JULIA_EDITOR = code
  JULIA_NUM_THREADS = 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions