As Kristoffer said, it’s basically impossible to help here without more code. I was able to modify your provided code in order to define the struct and I observe no allocations in accessing the name field:
julia> abstract type AbstractElement end
julia> mutable struct Element{T<:AbstractElement} <: AbstractElement
input::String
name::UnitRange{Int64}
attributes::Union{Nothing, Int}
value::Union{T, Nothing}
parent::Union{Element, Nothing}
next::Union{Element, Nothing}
end
julia> let e = Element{Element}("hi", 1:10, nothing, nothing, nothing, nothing)
@btime $e.name
end
1.299 ns (0 allocations: 0 bytes)
1:10
I suspect the allocations are caused by something else. What could be causing those allocations though is anybody’s guess, since nobody but you knows how you defined getname, getnext, _equals, or Attribute.