-
Notifications
You must be signed in to change notification settings - Fork 253
Description
** Please make sure you read the contribution guide and file the issues in the rigth place. **
Contribution guide.
Describe the bug
The InMemorySessionService has the following structure for storing a session
// Structure: appName -> userId -> sessionId -> Session
private final ConcurrentMap<String, ConcurrentMap<String, ConcurrentMap<String, Session>>>
sessions;
When we do deleteSession(appName, userId, sessionId) it only removes the session but leaves back an empty map for the userId and appName
What's deleted: sessionId → Session mapping
What's NOT deleted: Empty userId → {} map
What's NOT deleted: Empty appName → {} map ( This should still be fine )
Example:
BEFORE deletion:
sessions: {
"myApp": {
"user1": {
"ctx1": Session@1234
},
"user2": {
"ctx1": Session@1234
},
"user3": {
"ctx1": Session@1234
}
}
}
AFTER deletion:
sessions: {
"myApp": {
"user1": {} ← Empty map remains!
"user2": {} ← Empty map remains!
"user3": {} ← Empty map remains!
"user4": {} ← Empty map remains!
.
.
.
}
}
It can cause a potential MemoryLeak when there are a lot of users using the Agent
To Reproduce
Steps to reproduce the behavior:
- Install '...'
- Run '....'
- Open '....'
- See error
Expected behavior
An option to also delete the appName.userID map inside the InMemorySession
Screenshots
Before Deletion
After Deletion
Desktop (please complete the following information):
- OS: [e.g. iOS]
- Java version: 21
- ADK version(see maven dependency): 0.4.0
Additional context
Add any other context about the problem here.