# Static remain after Window closed

**URL:** <https://forum.xojo.com/t/static-remain-after-window-closed/66898>\
**Category:** General\
**Created:** [November 21, 2021, 4:27pm UTC](https://forum.xojo.com/t/static-remain-after-window-closed/66898 "2021-11-21T16:27:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas\_ROBISSON](https://forum.xojo.com/user_avatar/forum.xojo.com/thomas_robisson/32/15868_2.png) [@Thomas\_ROBISSON](https://forum.xojo.com/u/Thomas_ROBISSON)\
**Post date:** [November 21, 2021, 4:27pm UTC](https://forum.xojo.com/t/static-remain-after-window-closed/66898/1 "2021-11-21T16:27:17Z")

</div>

I have an additional window with a Method which contains a Static.  
After I close this additional window, when I re-open it and I recall the Method, the Static keeps the value I assigned and is not re-initialised. Is it normal?  
[Doc Static](https://documentation.xojo.com/api/language/static.html) : It is written " A Static variable is equivalent to a local variable declared by the [Var](https://documentation.xojo.com/api/language/var.html) statement but its value is retained between several calls of the method it is declared in."  
Then, as Var are destroyed (free memory) when we close a window, I thought it was the same for Static.  
Launch this small project [WindowMethodStatic.xojo\_binary\_project.](http://tom.25.free.fr/Documents/WindowMethodStatic.zip)  
Run it, Open Window2, click “update static” many time. Close this window2.  
Re-open it, re-click “update static”, this is not 0 but the last value.

---

<div class="post-metadata">

**Author:** ![DerkJ](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@DerkJ](https://forum.xojo.com/u/DerkJ)\
**Post date:** [November 21, 2021, 4:39pm UTC](https://forum.xojo.com/t/static-remain-after-window-closed/66898/2 "2021-11-21T16:39:34Z")

</div>

It should always keep its value unless re-assigned.  
If you close the window it’s retained, thus the value should remain as-is.

---

<div class="post-metadata">

**Author:** ![anon20074439](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@anon20074439](https://forum.xojo.com/u/anon20074439)\
**Post date:** [November 21, 2021, 4:41pm UTC](https://forum.xojo.com/t/static-remain-after-window-closed/66898/3 "2021-11-21T16:41:23Z")

</div>

Your quote just ended a little early:

“Also, all the instances of a given class share the same static values.”

It’s no different to a Shared Property other than you can define it in code instead of through the IDE.

---

<div class="post-metadata">

**Author:** ![Thomas\_ROBISSON](https://forum.xojo.com/user_avatar/forum.xojo.com/thomas_robisson/32/15868_2.png) [@Thomas\_ROBISSON](https://forum.xojo.com/u/Thomas_ROBISSON)\
**Post date:** [November 22, 2021, 10:05am UTC](https://forum.xojo.com/t/static-remain-after-window-closed/66898/4 "2021-11-22T10:05:23Z")

</div>

Thank you very much for yours answers.
