Kyryl Zotov
Kyryl Zotov

Reputation: 1968

Is there any way to release (clean) static fields

Is there any way to release(clean) static fields ect. Singletons or constant values when exit Android app?

Upvotes: 2

Views: 1867

Answers (3)

Ashish Shukla
Ashish Shukla

Reputation: 1047

No I dont think there's any other way except assigning individual variables to null ,release your resources in the onStop() or onPause()

Upvotes: 1

Yaroslav Mytkalyk
Yaroslav Mytkalyk

Reputation: 17115

You can assign the fields of types that extend Object to null. This way, if there are no more references they can be collected by GC.

The primitive types will be released only when their owner class Object is collected.

Upvotes: 5

StenSoft
StenSoft

Reputation: 9609

When an Android application exits, all of its data is released. You can release the fields also by simply assiging null to them.

Upvotes: 6

Related Questions