# Associative array not cleared when function is done

**URL:** <https://verificationacademy.com/forums/t/associative-array-not-cleared-when-function-is-done/41655>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, associative\_arrays\
**Created:** [May 14, 2023, 1:28am UTC](https://verificationacademy.com/forums/t/associative-array-not-cleared-when-function-is-done/41655 "2023-05-14T01:28:25Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [May 14, 2023, 4:20am UTC](https://verificationacademy.com/forums/t/associative-array-not-cleared-when-function-is-done/41655/2 "2023-05-14T04:20:19Z")

</div>

_In reply to [wyc123](https://verificationacademy.com/forums/t/associative-array-not-cleared-when-function-is-done/41655):_

That is because your function has a static lifetime, and all the variables declared inside the function (as well its arguments and return value) have a implicitly static lifetime as well.

You need to declare the function with an automatic lifetime (preferred), or the individual variables you want. See [The life of a SystemVerilog Variable.](https://resources.sw.siemens.com/en-US/white-paper-the-life-of-a-systemverilog-variable)

---

_[View the full topic](https://verificationacademy.com/forums/t/associative-array-not-cleared-when-function-is-done/41655)._
