# Updatable LinesMesh, can't add or remove points

**URL:** <https://forum.babylonjs.com/t/updatable-linesmesh-cant-add-or-remove-points/40398>\
**Category:** Bugs\
**Created:** [May 1, 2023, 12:21pm UTC](https://forum.babylonjs.com/t/updatable-linesmesh-cant-add-or-remove-points/40398 "2023-05-01T12:21:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nnholo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nnholo/32/25249_2.png) [@nnholo](https://forum.babylonjs.com/u/nnholo)\
**Post date:** [May 1, 2023, 12:21pm UTC](https://forum.babylonjs.com/t/updatable-linesmesh-cant-add-or-remove-points/40398/1 "2023-05-01T12:21:52Z")

</div>

I’m attempting to draw a line through some points in 3D space with a little ball along each point. The set of points should be fully updatable.

I can update the points of a LinesMesh to move them around, but adding or remove points does not work as expected. Old line segments do not get removed, nor do new ones appear.

> **[Babylon.js Playground](https://www.babylonjs-playground.com/#FE5WQU%232)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [May 1, 2023, 7:03pm UTC](https://forum.babylonjs.com/t/updatable-linesmesh-cant-add-or-remove-points/40398/2 "2023-05-01T19:03:30Z")

</div>

As the doc says:

```auto
* When updating an instance, remember that only point positions can change, not the number of points

```

If the number of points change, you must recreate the line system.

You can also try to create the line system with the maximum number of points you will have and define the same coordinates for all the last points of the array.

---

<div class="post-metadata">

**Author:** ![nnholo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nnholo/32/25249_2.png) [@nnholo](https://forum.babylonjs.com/u/nnholo)\
**Post date:** [May 2, 2023, 11:40am UTC](https://forum.babylonjs.com/t/updatable-linesmesh-cant-add-or-remove-points/40398/3 "2023-05-02T11:40:06Z")

</div>

Thank you. Which document are you referring to? I didn’t come across it.

My first implementation actually did this, unfortunately even though I .dispose()d my LinesMesh before making a new one, I saw heap usage grow by several megabytes each time around (for a LinesMesh of a handful of points plus the same number of Spheres) without going back down. Since the mesh needs to be updated quite frequently, this quickly led to crashes.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [May 2, 2023, 1:14pm UTC](https://forum.babylonjs.com/t/updatable-linesmesh-cant-add-or-remove-points/40398/4 "2023-05-02T13:14:56Z")

</div>

It is the documentation of the `options` parameter of the `CreateLines` function:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/0/6/065c6f4e8cee70e7367857730fa09d0209194f9a.png)

Recreating a new `LinesMesh` should not leak memory, as long as you dispose the previous one: are you able to reproduce this behavior in the Playground?
