title: Background concurrent copying GC when Login
body: <p>MainActivity.kt</p>
  <pre><code>override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContent {
          val navController = rememberNavController()
          NavHost(
              navController = navController,
              startDestination = Screen.LoginScreen.route
          ) {
              composable(route = Screen.LoginScreen.route) {
                  navBackStackEntry -&gt;
                  val factory = HiltViewModelFactory(LocalContext.current, navBackStackEntry)
                  val viewModel: LoginViewModel = viewModel(key = &quot;LoginViewModel&quot;, factory = factory)
                  LoginScreen(
                      viewModel = viewModel,
                      onNavigateToNextScreen = navController::navigate,
                      navController = navController
                  )
              }
              composable(route = Screen.HomeScreen.route) {
                  navBackStackEntry -&gt;
                  val factory = HiltViewModelFactory(LocalContext.current, navBackStackEntry)
                  val viewModel: HomeViewModel = viewModel(key = &quot;HomeViewModel&quot;, factory = factory)
                  HomeScreen(
  
                  )
              }
          }
      }
  }
  </code></pre>
  <p>Screen.kt</p>
  <pre><code>sealed class Screen (
      val route: String,
  ){
      object LoginScreen: Screen(&quot;loginScreen&quot;)
      object HomeScreen: Screen(&quot;homeScreen&quot;)
  }
  </code></pre>
  <p>LoginScreen.kt</p>
  <pre><code>@OptIn(ExperimentalComposeUiApi::class)
  @Composable
  fun LoginScreen(
      viewModel: LoginViewModel,
      onNavigateToNextScreen: (String) -&gt; Unit,
      navController: NavController
  ) {
      val focusManager = LocalFocusManager.current
      val keyboardController = LocalSoftwareKeyboardController.current
  
      val empno = viewModel.empno.value
      val password = viewModel.password.value
      val loading = viewModel.loading.value
      val user = viewModel.user.value
      val dialogQueue = viewModel.dialogQueue
  
      var isPasswordVisible by remember {
          mutableStateOf(false)
      }
      val isFormValid by derivedStateOf {
          empno.isNotBlank() &amp;&amp; password.isNotBlank()
      }
      
      Scaffold(backgroundColor = Color.White) {
          Column(
              modifier = Modifier.fillMaxSize(),
              horizontalAlignment = Alignment.CenterHorizontally,
              verticalArrangement = Arrangement.Top
          ) {
              if (loading &amp;&amp; user == null) {
                  LoadingRecipeShimmer(imageHeight = IMAGE_HEIGHT.dp)
              }
              else if (!loading &amp;&amp; user != null) {
                  //Something to do.
                  val route = Screen.HomeScreen.route
                  onNavigateToNextScreen(route)
              }else {
                  Spacer(modifier = Modifier.height(16.dp))
                  Image(
                      painter = painterResource(id = R.drawable.image_login),
                      contentDescription = &quot;loginImage&quot;,
                      modifier = Modifier
                          .weight(1f)
                          .size(300.dp)
                  )
                  Card(
                      modifier = Modifier
                          .weight(2f)
                          .padding(8.dp),
                      shape = RoundedCornerShape(32.dp)
                  ) {
                      Column(
                          modifier = Modifier
                              .fillMaxSize()
                              .padding(32.dp),
                          horizontalAlignment = Alignment.CenterHorizontally,
                          verticalArrangement = Arrangement.Center
                      ) {
                          Text(
                              text = &quot;CompanyApp&quot;,
                              fontWeight = FontWeight.Bold,
                              fontSize = 40.sp
                          )
                          Column(
                              Modifier.fillMaxSize(),
                              horizontalAlignment = Alignment.CenterHorizontally,
                              verticalArrangement = Arrangement.Center
                          ) {
                              Spacer(modifier = Modifier.weight(1f))
                              OutlinedTextField(
                                  value = empno,
                                  onValueChange = {
                                      viewModel.setEmpno(it)
                                  },
                                  modifier = Modifier
                                      .fillMaxWidth(),
                                  label = { Text(text = &quot;EmployeeNumber&quot;) },
                                  singleLine = true,
                                  keyboardOptions = KeyboardOptions(
                                      keyboardType = KeyboardType.Number,
                                      imeAction = ImeAction.Next
                                  ),
                                  keyboardActions = KeyboardActions(
                                      onNext = {
                                          focusManager.moveFocus(FocusDirection.Down)
                                      }
                                  ),
                                  trailingIcon = {
                                      if (empno.isNotBlank()) {
                                          IconButton(
                                              onClick = {
                                                  viewModel.setEmpno(&quot;&quot;)
                                              }) {
                                              Icon(
                                                  imageVector = Icons.Filled.Clear,
                                                  contentDescription = &quot;&quot;)
                                          }
                                      }
                                  }
                              )
                              Spacer(modifier = Modifier.height(16.dp))
                              OutlinedTextField(
                                  value = password,
                                  onValueChange = {
                                      viewModel.setPassword(it)
                                  },
                                  modifier = Modifier
                                      .fillMaxWidth(),
                                  label = { Text(text = &quot;Password&quot;) },
                                  singleLine = true,
                                  keyboardOptions = KeyboardOptions(
                                      keyboardType = KeyboardType.NumberPassword,
                                      imeAction = ImeAction.Done
                                  ),
                                  keyboardActions = KeyboardActions(
                                      onDone = {
                                          keyboardController?.hide()
                                          viewModel.login()
                                      }
                                  ),
                                  visualTransformation = if (isPasswordVisible) VisualTransformation.None else PasswordVisualTransformation(),
                                  trailingIcon = {
                                      IconButton(onClick = { isPasswordVisible = !isPasswordVisible }) {
                                          Icon(
                                              imageVector = if (isPasswordVisible) Icons.Default.Visibility else Icons.Default.VisibilityOff,
                                              contentDescription = &quot;Password Toggle&quot;
                                          )
                                      }
                                  }
                              )
                              Spacer(modifier = Modifier.height(16.dp))
                              Button(
                                  onClick = {
                                      keyboardController?.hide()
                                      viewModel.login()
                                  },
                                  enabled = isFormValid,
                                  modifier = Modifier
                                      .fillMaxWidth()
                                      .height(60.dp),
                                  shape = RoundedCornerShape(16.dp)
                              ) {
                                  Text(text = &quot;Login&quot;)
                              }
                              Spacer(modifier = Modifier.weight(1f))
                          }
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  <p>LoginViewModel.kt</p>
  <pre><code>@HiltViewModel
  class LoginViewModel @Inject constructor(
      private val login: Login,
      private val connectivityManager: ConnectivityManager,
      private val state: SavedStateHandle
  ) : ViewModel() {
  
      val empno = mutableStateOf(&quot;&quot;)
      val password = mutableStateOf(&quot;&quot;)
      val user: MutableState&lt;User?&gt; = mutableStateOf(null)
  
      val loading = mutableStateOf(false)
      val onLoad: MutableState&lt;Boolean&gt; = mutableStateOf(false)
      val dialogQueue = DialogQueue()
  
      fun setEmpno(empno: String) {
          this.empno.value = empno
      }
      fun setPassword(password: String) {
          this.password.value = password
      }
  
      init {
      }
  
  
      fun login() {
          val auth = Auth(store_code = &quot;2001&quot;, empno = empno.value, password = password.value)
          login.execute(auth).onEach { dataState -&gt;
              loading.value = dataState.loading
  
              dataState.data?.let { data -&gt;
                  user.value = data
              }
  
              dataState.error?.let { error -&gt;
                  Log.e(TAG, &quot;getRecipe: ${error}&quot;)
                  dialogQueue.appendErrorMessage(&quot;An Error Occurred&quot;, error)
              }
          }.launchIn(viewModelScope)
      }
  }
  </code></pre>
  <p>HomeScreen.kt</p>
  <pre><code>@Composable
  fun HomeScreen(
  
  ) {
      Card(
          modifier = Modifier.fillMaxSize()
      ) {
          Column(
              modifier = Modifier.fillMaxSize(),
              horizontalAlignment = Alignment.CenterHorizontally,
              verticalArrangement = Arrangement.Center
          ) {
              Text(
                  text = &quot;HomeScreen&quot;,
                  fontWeight = FontWeight.Bold,
                  fontSize = 40.sp
              )
          }
      }
  }
  </code></pre>
  <p>Press login button to try log in and receive user information, it's made to move on to the next screen.(HomeScreen)
  However, when log in and go to the next HomeScreen, the screen flashes and outputs the following message.</p>
  <pre><code>Background concurrent copying GC freed 821063(20MB) AllocSpace objects, 4(1176KB) LOS objects, 49% free, 19MB/38MB, paused 77us total 100.203ms
  2021-11-01 11:51:04.493 32596-4299/com.woorimart.projectapp I/rt.woorimartap: Background concurrent copying GC freed 783275(19MB) AllocSpace objects, 3(960KB) LOS objects, 49% free, 21MB/43MB, paused 42us total 107.347ms
  2021-11-01 11:51:12.030 32596-4299/com.woorimart.projectapp I/rt.woorimartap: Background concurrent copying GC freed 905429(22MB) AllocSpace objects, 3(768KB) LOS objects, 49% free, 23MB/46MB, paused 43us total 112.243ms
  2021-11-01 11:51:15.313 32596-4299/com.woorimart.projectapp I/rt.woorimartap: Background concurrent copying GC freed 951843(23MB) AllocSpace objects, 3(1184KB) LOS objects, 48% free, 25MB/49MB, paused 38us total 114.812ms
  2021-11-01 11:51:22.273 32596-4299/com.woorimart.projectapp I/rt.woorimartap: Background concurrent copying GC freed 1030020(25MB) AllocSpace objects, 2(872KB) LOS objects, 47% free, 26MB/50MB, paused 45us total 101.114ms
  2021-11-01 11:51:36.202 32596-4299/com.woorimart.projectapp I/rt.woorimartap: Background concurrent copying GC freed 1035054(25MB) AllocSpace objects, 2(1008KB) LOS objects, 44% free, 30MB/54MB, paused 42us total 126.748ms
  2021-11-01 11:51:38.349 32596-4299/com.woorimart.projectapp I/rt.woorimartap: Background concurrent copying GC freed 903031(22MB) AllocSpace objects, 3(3596KB) LOS objects, 41% free, 33MB/57MB, paused 40us total 127.925ms
  2021-11-01 11:51:41.070 32596-4299/com.woorimart.projectapp I/rt.woorimartap: Background concurrent copying GC freed 975005(24MB) AllocSpace objects, 3(1584KB) LOS objects, 40% free, 35MB/59MB, paused 46us total 106.787ms
  </code></pre>
  <p>I looked it up on the Internet and found that it was if gson did not match, but when I printed the value in Log.d, the value was printed normally.
  If there is anything I need to add before moving on to the next screen, please let me know.</p>
  <hr />
  <p>Edit.
  I've done some experiments.
  When I put the code of HomeScreen into LoginScreen and change the screen, freezing does not occur.</p>
  <p>Like this,</p>
  <pre><code>...
              else if (!loading &amp;&amp; user != null) {
                  //Something to do.
                  //navController.navigate(Screen.HomeScreen.route)
                  Card(
                      modifier = Modifier.fillMaxSize()
                  ) {
                      Column(
                          modifier = Modifier.fillMaxSize(),
                          horizontalAlignment = Alignment.CenterHorizontally,
                          verticalArrangement = Arrangement.Center
                      ) {
                          Text(
                              text = &quot;HomeScreen&quot;,
                              fontWeight = FontWeight.Bold,
                              fontSize = 40.sp
                          )
                      }
                  }
              }else {
  ...
  </code></pre>
  <p>There seems to be a problem with Main Activity's code, but I can't guess what's wrong. Please let me know if you know.</p>