mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-19 16:57:40 +03:00
Navigator: don't leak memory via PartyState (#12896)
Undoing an unnecessary refactoring from #12187 stefanobaghino-da confirmed this fixes the memory leak he observed in "long" running navigator sessions. CHANGELOG_BEGIN CHANGELOG_END
This commit is contained in:
parent
3dccabf6ba
commit
3ebd9d7be0
@ -270,7 +270,9 @@ abstract class UIBackend extends LazyLogging with ApplicationInfoJsonSupport {
|
||||
config.users.foreach { case (displayName, config) =>
|
||||
store ! Subscribe(
|
||||
displayName,
|
||||
new PartyState(config.party, config.role, config.useDatabase),
|
||||
config.party,
|
||||
config.role,
|
||||
config.useDatabase,
|
||||
)
|
||||
}
|
||||
None
|
||||
|
@ -34,7 +34,12 @@ object Store {
|
||||
case class UpdatedParties(details: List[PartyDetails])
|
||||
|
||||
/** Request to subscribe a party to the store (without response to sender). */
|
||||
case class Subscribe(displayName: String, partyState: PartyState)
|
||||
case class Subscribe(
|
||||
displayName: String,
|
||||
name: ApiTypes.Party,
|
||||
userRole: Option[String] = None,
|
||||
useDatabase: Boolean = false,
|
||||
)
|
||||
|
||||
/** Request to create a contract instance for a template and respond with a `scala.util.Try[CommandId]`. */
|
||||
case class CreateContract(party: PartyState, templateId: TemplateStringId, argument: ApiRecord)
|
||||
|
@ -218,22 +218,24 @@ class PlatformStore(
|
||||
}
|
||||
|
||||
usersWithPrimaryParties.foreach { case (userId, party) =>
|
||||
self ! Subscribe(userId, new PartyState(ApiTypes.Party(party)))
|
||||
self ! Subscribe(userId, ApiTypes.Party(party))
|
||||
}
|
||||
|
||||
case UpdatedParties(details) =>
|
||||
details.foreach { partyDetails =>
|
||||
if (partyDetails.isLocal) {
|
||||
val displayName = partyDetails.displayName.getOrElse(partyDetails.party)
|
||||
self ! Subscribe(displayName, new PartyState(ApiTypes.Party(partyDetails.party)))
|
||||
self ! Subscribe(displayName, ApiTypes.Party(partyDetails.party))
|
||||
} else {
|
||||
log.debug(s"Ignoring non-local party ${partyDetails.party}")
|
||||
}
|
||||
}
|
||||
|
||||
case Subscribe(displayName, partyState) =>
|
||||
case Subscribe(displayName, name, userRole, useDatabase) =>
|
||||
if (!state.parties.contains(displayName)) {
|
||||
log.info(s"Starting actor for ${partyState.name} (aka $displayName)")
|
||||
val partyState =
|
||||
new PartyState(name, userRole, useDatabase) // do this allocation only once per party
|
||||
log.info(s"Starting actor for party ${partyState.name} (display name $displayName)")
|
||||
|
||||
// start party actor if needed (since users subscribe to their primary party,
|
||||
// we may subscribe to the same party under different display names, but we should only create one actor per party)
|
||||
@ -247,7 +249,7 @@ class PlatformStore(
|
||||
val updatedParties = state.parties + (displayName -> partyState)
|
||||
context.become(connected(state.copy(parties = updatedParties)))
|
||||
} else {
|
||||
log.debug(s"Actor for ${partyState.name} (aka $displayName) is already running")
|
||||
log.debug(s"Actor for party $name (display name $displayName) is already running")
|
||||
}
|
||||
|
||||
case CreateContract(party, templateId, value) =>
|
||||
|
Loading…
Reference in New Issue
Block a user