Skip to content

Fix the memory leak in the sample app#199

Merged
cy245 merged 2 commits into
android:mainfrom
NightXlt:patch-1
May 26, 2026
Merged

Fix the memory leak in the sample app#199
cy245 merged 2 commits into
android:mainfrom
NightXlt:patch-1

Conversation

@NightXlt
Copy link
Copy Markdown
Contributor

Replace the activity context to application context to prevent memory leak in Activity reconstruction case.

Replace the activity context to application context to prevent memory leak in Activity reconstruction case.
@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 25, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the JsonProvider class to store the application context in a property. A review comment suggests marking this new context property as private to maintain encapsulation, as it is currently public by default.

class JsonProvider(private val context: Context) {
class JsonProvider(context: Context) {

val context = context.applicationContext
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The context property is now public, which exposes the internal state of the class. It should be marked as private to maintain encapsulation, as it was in the previous version.

Suggested change
val context = context.applicationContext
private val context = context.applicationContext

@niharika2810
Copy link
Copy Markdown
Collaborator

HI Thanks for raising this. Can you check the sample if it is reproducible in that point your changes here then : https://github.com/android/identity-samples/tree/main/Shrine

as we might be deprecating or shifting compose sample to main soon.

@cy245 cy245 merged commit 53af999 into android:main May 26, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants