# Variable of Blueprint Function Library keeps data after stopping game in editor

**URL:** <https://forums.unrealengine.com/t/variable-of-blueprint-function-library-keeps-data-after-stopping-game-in-editor/258918>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [November 2, 2021, 11:03am UTC](https://forums.unrealengine.com/t/variable-of-blueprint-function-library-keeps-data-after-stopping-game-in-editor/258918 "2021-11-02T11:03:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_308f0a98](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_308f0a98](https://forums.unrealengine.com/u/anonymous_user_308f0a98)\
**Post date:** [November 2, 2021, 11:03am UTC](https://forums.unrealengine.com/t/variable-of-blueprint-function-library-keeps-data-after-stopping-game-in-editor/258918/1 "2021-11-02T11:03:15Z")

</div>

Hello,

As written in the title, I have variable TMap in a blueprint function library class which I created to keep data while calling functions of that blueprint function library.

It seems that even after closing the game in editor, map keeps data. After packaging, it does not keep data.

Is there any way to reset map when game is closed in editor? Thanks!

---

<div class="post-metadata">

**Author:** ![and-rad](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@and-rad](https://forums.unrealengine.com/u/and-rad)\
**Post date:** [November 2, 2021, 11:28am UTC](https://forums.unrealengine.com/t/variable-of-blueprint-function-library-keeps-data-after-stopping-game-in-editor/258918/2 "2021-11-02T11:28:23Z")

</div>

Is it a static variable? If so, that’s completely normal. It would be your responsibility to clean it up after the PIE session ends.

Take a look at [this thread](https://forums.unrealengine.com/t/static-variables-being-kept-between-editor-play-sessions/257842) where we discussed something similar.

In short: find a suitable point in the game lifecycle and clean up all your statics.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_308f0a98](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_308f0a98](https://forums.unrealengine.com/u/anonymous_user_308f0a98)\
**Post date:** [November 4, 2021, 2:13am UTC](https://forums.unrealengine.com/t/variable-of-blueprint-function-library-keeps-data-after-stopping-game-in-editor/258918/3 "2021-11-04T02:13:07Z")

</div>

Thanks @and-rad  
But do you happen to know how to use UGameInstance::OnStart() in a blueprint function library? I am searching ways, have not found yet.

---

<div class="post-metadata">

**Author:** ![and-rad](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@and-rad](https://forums.unrealengine.com/u/and-rad)\
**Post date:** [November 4, 2021, 9:02am UTC](https://forums.unrealengine.com/t/variable-of-blueprint-function-library-keeps-data-after-stopping-game-in-editor/258918/4 "2021-11-04T09:02:52Z")

</div>

Why would you do that? You override `UGameInstance::OnStart` and add your own functionality. The engine calls the function when it is time.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_308f0a98](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_308f0a98](https://forums.unrealengine.com/u/anonymous_user_308f0a98)\
**Post date:** [November 4, 2021, 9:49am UTC](https://forums.unrealengine.com/t/variable-of-blueprint-function-library-keeps-data-after-stopping-game-in-editor/258918/5 "2021-11-04T09:49:26Z")

</div>

Thanks you for your help mate!
