Memory issue when transferring data from a local realm to a synchronized realm

Hey.
I am trying to transfer data from local realm to SyncRealm using the following code:

Local to sync
SyncConfiguration syncRealmConfig = user
                .createConfiguration(Constants.REALM_URL + "/~/my-project")
                .fullSynchronization()
                .waitForInitialRemoteData(5, TimeUnit.MINUTES)
                .initialData(initRealm -> {
                    Realm localRealm = mDatabaseHandler.createRealmInstance();
                    Set<Class<? extends RealmModel>> realmObjectClasses = localRealm.getConfiguration().getRealmObjectClasses();
                    for (Class<? extends RealmModel> realmObjectClass : realmObjectClasses) {
                        RealmResults<? extends RealmModel> realmModels = localRealm.where(realmObjectClass).findAll();
                        // I tried to use "insertOrUpdate", but the result does not change
                        // initRealm.insertOrUpdate(realmModels);
                        initRealm.copyToRealmOrUpdate(realmModels);
                    }
                })
                .build();
        Realm.getInstanceAsync(syncRealmConfig, new Realm.Callback() {
            @Override
            public void onSuccess(@NonNull Realm initRealm) {
                showProgress(false);
                gotoMainActivity();
            }
        });

During data transfer, the application data size begins to increase rapidly (local database size is ~ 20 MB, and after transferring data to RealmSync, the application size is ~ 300 MB).

I noticed the following changes in the application file system

Images

/data/data/“MyApp”/files

  1. At the beginning of the transfer
    image
  2. During transfer
    image

What am I doing wrong? Is it possible to reduce the size of the used memory during the transfer?