# Release memory after script is finished

**URL:** <https://scilab.discourse.group/t/release-memory-after-script-is-finished/1072>\
**Category:** General usage\
**Created:** [October 27, 2025, 2:24pm UTC](https://scilab.discourse.group/t/release-memory-after-script-is-finished/1072 "2025-10-27T14:24:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![philipp](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/philipp/32/53_2.png) [@philipp](https://scilab.discourse.group/u/philipp)\
**Post date:** [October 27, 2025, 2:24pm UTC](https://scilab.discourse.group/t/release-memory-after-script-is-finished/1072/1 "2025-10-27T14:24:39Z")

</div>

Hi,

I have a script which simply loads a bunch of data files ( csvRead() ) and draws a huge amount of data points into a single graph.

After exporting the graph to an png-file (xs2png()) I want to release all occupied memory without closing Scilab.

However that doesn’t really work:

During process Scilab occupied \> 50 GB of RAM

- close() –\> to possibly free memory of the graph –\> did not reduce Scilab memory usage
- clear() –\> to possible free memory of variables –\> did not reduce Scilab memory usage

Working with Win11 and Scilab 2025.1.0 and using windows task manager to view memory.

Only when closing Scilab the memory is freed.

Is there any function that I am missing to set Scilab back to “init use of memory” ?

Thank you,

Philipp

---

<div class="post-metadata">

**Author:** ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)\
**Post date:** [October 27, 2025, 3:43pm UTC](https://scilab.discourse.group/t/release-memory-after-script-is-finished/1072/2 "2025-10-27T15:43:13Z")

</div>

Hello Philipp,

If you go to [Issues · scilab / scilab · GitLab](https://gitlab.com/scilab/scilab/-/issues) and search for the term “memory leak” you will see that many graphical internals suffer from this disease. Sometimes deleting objects at a lower level (instead of deleting the figure) partly fixes the memory problem. But there is no magic solution. If you could write a small example causing the memory leak it may help to find where the problem comes from.

S.

---

<div class="post-metadata">

**Author:** ![davidcl](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/davidcl/32/1029_2.png) [@davidcl](https://scilab.discourse.group/u/davidcl)\
**Post date:** [October 28, 2025, 7:33am UTC](https://scilab.discourse.group/t/release-memory-after-script-is-finished/1072/3 "2025-10-28T07:33:58Z")

</div>

Hi Philipp,

I second Stephane here, please post a simple script with the same function calls (eg. graphical function, data point, xs2png, etc…).

Note: your system memory is used when available, all graphical objects are stored in the JVM, and the memory is only reclaimed when needed.

---

<div class="post-metadata">

**Author:** ![philipp](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/philipp/32/53_2.png) [@philipp](https://scilab.discourse.group/u/philipp)\
**Post date:** [October 28, 2025, 1:23pm UTC](https://scilab.discourse.group/t/release-memory-after-script-is-finished/1072/4 "2025-10-28T13:23:20Z")

</div>

Hi,

you may find an example here: [memory leak using plot (#17490) · Issues · scilab / scilab · GitLab](https://gitlab.com/scilab/scilab/-/issues/17490)

The example does not include all used functions such as `csvRead` or `xs2png` since I can reproduce the memory leakage using only `figure`, `plot`, `drawnow`, etc

My observation is, that memory is occupied noticeably when using `plot` and after `drawnow`

**@ David:**

> the memory is only reclaimed when needed

What does this mean exactly? Scilab continues to “block” once occupied memory, even if it actually does not need it? This memory is assigned to Scilab until another software needs it?

What I experience is that Scilab starts from a different (higher) RAM level after using plot.This occurs when I run my script several times in a row without closing Scilab in between.

Thank you,

Philipp

---

<div class="post-metadata">

**Author:** ![davidcl](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/davidcl/32/1029_2.png) [@davidcl](https://scilab.discourse.group/u/davidcl)\
**Post date:** [November 17, 2025, 8:58am UTC](https://scilab.discourse.group/t/release-memory-after-script-is-finished/1072/5 "2025-11-17T08:58:18Z")

</div>

In software using GC (in Scilab some of the graphic data are stored in Java; the rendering is using Java), the information is stored and the memory is released only when the GC decides to kick in. For more information, you can read [What is Garbage Collection in Java? | IBM](https://www.ibm.com/think/topics/garbage-collection-java) .

Thank you for reporting an issue. We will investigate it and determine if it is expected behaviour (the data is still needed) or if it is a memory leak.
