# OPENRNDR filling up computer memory and crashing | Making a variable-width line

**URL:** <https://openrndr.discourse.group/t/openrndr-filling-up-computer-memory-and-crashing-making-a-variable-width-line/327>\
**Category:** How to?\
**Created:** [January 29, 2022, 11:43am UTC](https://openrndr.discourse.group/t/openrndr-filling-up-computer-memory-and-crashing-making-a-variable-width-line/327 "2022-01-29T11:43:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ehr](https://avatars.discourse-cdn.com/v4/letter/e/eb8c5e/32.png) [@ehr](https://openrndr.discourse.group/u/ehr)\
**Post date:** [January 29, 2022, 11:43am UTC](https://openrndr.discourse.group/t/openrndr-filling-up-computer-memory-and-crashing-making-a-variable-width-line/327/1 "2022-01-29T11:43:31Z")

</div>

I am trying to draw a variable width line by using an array of circles that I add circles with different radi to.  
Every frame (inside the `extend` block) the sketch processes 50 new circles and adds them to a `MutableList` which is then drawn using `drawer.circles()`.

Once the sketch has been running for a long enough time it completely fills up the computers memory and causes it to crash.

I understand that this is probably not the best way to do what I’m trying to do, but can’t think of any other way of drawing dynamic-width lines.

It would probably help if I didn’t have to store all of the circles in a list, but could draw them on the screen and not have them cleared when the next frame is rendered.

Lmk if you can help,  
Cheers!

---

<div class="post-metadata">

**Author:** ![abe](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/abe/32/700_2.png) [@abe](https://openrndr.discourse.group/u/abe)\
**Post date:** [January 29, 2022, 1:22pm UTC](https://openrndr.discourse.group/t/openrndr-filling-up-computer-memory-and-crashing-making-a-variable-width-line/327/2 "2022-01-29T13:22:24Z")

</div>

Terve Eino! 🙂

And welcome to the forum 🙂 There are several ways to do that. Maybe the easiest is to use orx-no-clear which allows you to draw and keep the previous content visible. That way you only draw one circle.

> <https://github.com/openrndr/orx/tree/master/orx-no-clear>
>
> //github.com/openrndr/orx/tree/master/orx-no-clear

Or create your own [RenderTarget](https://guide.openrndr.org/advancedDrawing/renderTargets.html) instead (that’s what orx-no-clear does for you behind the scenes).

If you want to draw an animated morphing variable thickness line you could take this different approach, but it’s a bit more convoluted:

> [@Drawing per-vertex colored meshes and variable thickness lines](https://openrndr.discourse.group/t/drawing-per-vertex-colored-meshes-and-variable-thickness-lines/266/2):
>
> The code above was a preparation for this program, which converts an open animated shapeContour into a mesh (a triangle strip) with variable width and unique colors per vertex. 
> 
> > **imports**
> >
> > import org.openrndr.application import org.openrndr.color.ColorRGBa import org.openrndr.draw.DrawPrimitive import org.openrndr.draw.shadeStyle import org.openrndr.draw.vertexBuffer import org.openrndr.draw.vertexFormat import org.openrndr.extensions.Screenshots import org.openrndr.extra.noise.Random import org.ope…

I’ll create an easy to use function and post it as a reply later.

ps. Feel free to share an image of what you are trying to create (here in the forum or somewhere else like [https://imgur.com/](https://imgur.com/) if you can’t yet share images here): maybe a different approach comes to mind when I see it.

Cheers!

---

<div class="post-metadata">

**Author:** ![ehr](https://avatars.discourse-cdn.com/v4/letter/e/eb8c5e/32.png) [@ehr](https://openrndr.discourse.group/u/ehr)\
**Post date:** [January 29, 2022, 2:04pm UTC](https://openrndr.discourse.group/t/openrndr-filling-up-computer-memory-and-crashing-making-a-variable-width-line/327/3 "2022-01-29T14:04:34Z")

</div>

Thanks for the help. I think I’ll try orx-no-clear and then post an image.

Edit: apparently orx-no-clear is not in the current orx version so I’ll try doing it myself since it doesn’t seem that complicated.

---

<div class="post-metadata">

**Author:** ![ehr](https://avatars.discourse-cdn.com/v4/letter/e/eb8c5e/32.png) [@ehr](https://openrndr.discourse.group/u/ehr)\
**Post date:** [January 29, 2022, 2:31pm UTC](https://openrndr.discourse.group/t/openrndr-filling-up-computer-memory-and-crashing-making-a-variable-width-line/327/4 "2022-01-29T14:31:50Z")

</div>

The RenderTarget way worked, only that it seems lower resolution or interpolated somehow. I tried both with multisample AA and not.

 ![image](https://global.discourse-cdn.com/free1/uploads/openrndr/original/1X/8e2fa186f9af534235e6d82c6dfecd649c1f4843.jpeg)  
This is what I’m making. It takes an image to use as a “flow field” and to use as the size of the circles to draw the image.

![image](https://global.discourse-cdn.com/free1/uploads/openrndr/original/1X/86f94e2a09b9e7c3695e2718e98e66a5e9ca8da3.jpeg)

 ![image](https://global.discourse-cdn.com/free1/uploads/openrndr/original/1X/ca2a5f7bae5b9679fceaa27fddfd37549bc332d0.jpeg)

 ![image](https://global.discourse-cdn.com/free1/uploads/openrndr/original/1X/bc161542333ea1d3ed56425760b4f5c40a580f57.jpeg)

 ![image](https://global.discourse-cdn.com/free1/uploads/openrndr/original/1X/13774f9428d60a3c6b0db912bde27b1450edc156.jpeg)

 ![image](https://global.discourse-cdn.com/free1/uploads/openrndr/original/1X/ab4662f8925cd80f186c693ee34bc13e687f7ea8.jpeg)

 ![image](https://global.discourse-cdn.com/free1/uploads/openrndr/original/1X/ff48b5ee32637e314438c12c8777efe95fb95bb5.jpeg)

 ![image](https://global.discourse-cdn.com/free1/uploads/openrndr/original/1X/1434d06ea3aa63a80604ce60ad6c1e4975e641d3.jpeg)

---

<div class="post-metadata">

**Author:** ![abe](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/abe/32/700_2.png) [@abe](https://openrndr.discourse.group/u/abe)\
**Post date:** [January 29, 2022, 5:41pm UTC](https://openrndr.discourse.group/t/openrndr-filling-up-computer-memory-and-crashing-making-a-variable-width-line/327/5 "2022-01-29T17:41:50Z")

</div>

> [@ehr](#):
>
> Edit: apparently orx-no-clear is not in the current orx version so I’ll try doing it myself since it doesn’t seem that complicated.

That’s odd. I think it’s been there for a long time. Did you enable it in [build.gradle.kts](https://github.com/openrndr/openrndr-template/blob/master/build.gradle.kts#L37)?

---

<div class="post-metadata">

**Author:** ![abe](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/abe/32/700_2.png) [@abe](https://openrndr.discourse.group/u/abe)\
**Post date:** [January 29, 2022, 6:00pm UTC](https://openrndr.discourse.group/t/openrndr-filling-up-computer-memory-and-crashing-making-a-variable-width-line/327/6 "2022-01-29T18:00:30Z")

</div>

> [@ehr](#):
>
> it seems lower resolution or interpolated somehow

Is one of the images you posted the correct look and another one the “lower resolution” one?  
Did you set a stroke color / weight when drawing circles?

Ah… I think it may look different when you draw ten circles all in one frame and when you draw the same ten circles in ten different frames. Something worth trying.

ps. I wrote a [class to draw thick lines](https://openrndr.discourse.group/t/drawing-per-vertex-colored-meshes-and-variable-thickness-lines/266/3).

---

<div class="post-metadata">

**Author:** ![ehr](https://avatars.discourse-cdn.com/v4/letter/e/eb8c5e/32.png) [@ehr](https://openrndr.discourse.group/u/ehr)\
**Post date:** [February 6, 2022, 6:51pm UTC](https://openrndr.discourse.group/t/openrndr-filling-up-computer-memory-and-crashing-making-a-variable-width-line/327/7 "2022-02-06T18:51:45Z")

</div>

Nah, I don’t think I did. I didn’t know you had to do that, know I do. The other approach ended up suiting my needs better.

---

<div class="post-metadata">

**Author:** ![ehr](https://avatars.discourse-cdn.com/v4/letter/e/eb8c5e/32.png) [@ehr](https://openrndr.discourse.group/u/ehr)\
**Post date:** [February 6, 2022, 7:02pm UTC](https://openrndr.discourse.group/t/openrndr-filling-up-computer-memory-and-crashing-making-a-variable-width-line/327/8 "2022-02-06T19:02:51Z")

</div>

> [@abe](#):
>
> Is one of the images you posted the correct look and another one the “lower resolution” one?

All of the images are the blurrier seeming ones, I couldn’t get it working without this NoClear “hack”. It’s small enough to not really annoy me and I’m constantly working on stuff so I dunno how interested I am in trying to “fix” it.
