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

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")
                .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);
        Realm.getInstanceAsync(syncRealmConfig, new Realm.Callback() {
            public void onSuccess(@NonNull Realm initRealm) {

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



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

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