Skip to content

Creating a view (SubArray) of a Vector allocates memory #19257

Closed
@tkoolen

Description

On 0.5 as well as the latest nightly, for matrices,

@benchmark view(a, 1:2, 1:2) setup = (a = rand(3, 3))

results in zero allocation.

However,

@benchmark view(a, 1:2) setup = (a = rand(3))

results in 48 bytes of allocation and is almost 6 times slower. I haven't been able to figure out what in subarray.jl causes this.

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