# Memory{T} in 1.11

**URL:** https://discourse.julialang.org/t/memory-t-in-1-11/111811
**Category:** New to Julia
**Created:** [March 19, 2024, 10:18am UTC](https://discourse.julialang.org/t/memory-t-in-1-11/111811 "2024-03-19T10:18:10Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![gitboy16](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gitboy16/32/24906_2.png) [@gitboy16](https://discourse.julialang.org/u/gitboy16)
#### Post date: [March 19, 2024, 10:18am UTC](https://discourse.julialang.org/t/memory-t-in-1-11/111811/1 "2024-03-19T10:18:10Z")

</div>

Hi,

While running my code with the 1.11 alpha 2 version of Julia, it broke due (I think) to a change introduced in Julia 1.11.

In the following code:

```julia
d = IOBuffer("hello")
dd = d.data

```

`dd` is a Vector{UInt8} in julia 1.10 but is a Memory{UInt8} in 1.11.  
Which broke my code because there is no `insert!` function for Memory{UInt8}

1/ the Julia documentation says it is “One-dimensional dense array with element of type T.” What is the difference with Vector{T} ? And in which case should I use Memory?

2/ is there an easy way to convert Memory to Vector?

3/ is there a plan to add an insert function for Memory?

Thank you

---

<div class="post-metadata">

### Author: ![jakobnissen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jakobnissen/32/13477_2.png) [@jakobnissen](https://discourse.julialang.org/u/jakobnissen)
#### Post date: [March 19, 2024, 10:23am UTC](https://discourse.julialang.org/t/memory-t-in-1-11/111811/2 "2024-03-19T10:23:02Z")

</div>

In general, the fields of objects in Julia are considered internal. So, there is no guarantee that fields of objects don’t change in minor versions. I’ll admit it’s not at all clear to users of Julia what is and isn’t internal, though. To prevent issues like this in the future, I recommend structuring your code so you don’t need to access individual fields of types that are not your own. Anyway, to your questions:

1. Memory is more low-level, as it doesn’t support multiple axes (dimensions), and it can’t dynamically change size. You can think of a `Vector` as a Memory plus to integers - an offset and a length. If you know that you don’t need to resize a vector, `Memory` removes a small amount of overhead

2. `collect(mem)` to create a new Array copying the elements, and `wrap` to create a new array backed by the memory.

3. That’s not possible, because the whole idea of Memory is to be lower level, which is possibly precisely because it can’t change size. So that can’t be done.
