# Handling memory

**URL:** https://discourse.julialang.org/t/handling-memory/118692
**Category:** New to Julia
**Tags:** question
**Created:** [August 28, 2024, 4:22am UTC](https://discourse.julialang.org/t/handling-memory/118692 "2024-08-28T04:22:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![pnkgharde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pnkgharde/32/211615_2.png) [@pnkgharde](https://discourse.julialang.org/u/pnkgharde)
#### Post date: [August 28, 2024, 4:22am UTC](https://discourse.julialang.org/t/handling-memory/118692/1 "2024-08-28T04:22:51Z")

</div>

There is any function or option just like c/c++ pointer in julia ?

---

<div class="post-metadata">

### Author: ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)
#### Post date: [August 28, 2024, 5:18am UTC](https://discourse.julialang.org/t/handling-memory/118692/2 "2024-08-28T05:18:05Z")

</div>

In the upcoming Julia 1.11 you will have the `Memory` type which allows safe access to essentially raw memory.

Prior to that you can still work with things like `Libc.malloc`, `Ptr`, `convert(Ptr{Int}, pointer)`, `unsafe_load`, `unsafe_store!` etc. but this is no more safe than C/C++ and highly unidiomatic for Julia. It would be better to just use an `Array`. There is basically no overhead if you ensure type stability.

---

<div class="post-metadata">

### Author: ![Philippe\_Maincon1](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)
#### Post date: [August 28, 2024, 12:26pm UTC](https://discourse.julialang.org/t/handling-memory/118692/3 "2024-08-28T12:26:00Z")

</div>

Hi,

@abraemer’s answer is correct. But if you are new to Julia, I would answer by asking the question: why do you want pointers?

The reason I ask is that they are used very little, and only to solve some very specific problems. For example: the only point in my code were I use one is to pass it to a function, so the function can allocate memory for the output, _and_ whatever the function has computed is not lost, even if the function returns with an exception.

Julia allows you allocate and deallocate memory on the heap (cf. `Array`) and share it, without explicitly using pointers.

Maybe you could give an example of where you would think of using a pointer, so we can give you ideas on how to do without pointer, in a “julian” way?

🙂
