# Implementation Details of Vector (or Array in General) and String

**URL:** <https://discourse.julialang.org/t/implementation-details-of-vector-or-array-in-general-and-string/66069>\
**Category:** Internals & Design\
**Created:** [August 9, 2021, 9:23am UTC](https://discourse.julialang.org/t/implementation-details-of-vector-or-array-in-general-and-string/66069 "2021-08-09T09:23:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Depping](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_depping/32/27997_2.png) [@Paul\_Depping](https://discourse.julialang.org/u/Paul_Depping)\
**Post date:** [August 9, 2021, 9:23am UTC](https://discourse.julialang.org/t/implementation-details-of-vector-or-array-in-general-and-string/66069/1 "2021-08-09T09:23:48Z")

</div>

Im currently searching through the Julia Code of both Vector/Array and String, but so far I haven’t found any details on how these are actually structured at a low level.

From using `Base.summarysize`, I can guess that Vector uses 40 Bytes to store Information such as length, a pointer and capacity (like a lot of C++ Vector implementations do), and that String uses 8 Bytes + the length of the UTF-8 String, but I’m interested in where in the Code these are implemented. My Guess would be somewhere in the C/C++ Part of Julia, but I am unsure where exactly to search there.

Example of using `Base.summarysize`:

```nohighlight
sizeof(collect(1:100))
800

julia> Base.summarysize(collect(1:100))
840

julia> Base.summarysize([])
40

julia> Base.summarysize("")
8

julia> Base.summarysize("Hello World!")
20

julia> Base.summarysize("A")
9

julia> Base.summarysize("Ä")
10

```

---

<div class="post-metadata">

**Author:** ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)\
**Post date:** [August 9, 2021, 9:47am UTC](https://discourse.julialang.org/t/implementation-details-of-vector-or-array-in-general-and-string/66069/2 "2021-08-09T09:47:16Z")

</div>

The array type is defined here:

[https://github.com/JuliaLang/julia/blob/7005b7d68be7e6dddb6fba70de855df0abdf3c22/src/julia.h#L177](https://github.com/JuliaLang/julia/blob/7005b7d68be7e6dddb6fba70de855df0abdf3c22/src/julia.h#L177)

Most of the functionality is implemented in `src/array.c`:

[https://github.com/JuliaLang/julia/blob/master/src/array.c](https://github.com/JuliaLang/julia/blob/master/src/array.c)
