Realm created 17 gb of files on server root


(Ahsan Ali) #1

We are using Realm Cloud for real time chat and other different purposes in our nodejs express app. But after some time Realm has created heavy files 17 GB on the server root.

I want to know If I will delete those files will will it effect my data or anything else on the server. ? I want to delete it because I think its too much of storage. As we are using Realm cloud why its using system 17 GB storage?

Second thing is that. Is there any solution or feature of realm to use it without the generation of those heavy cache files or in simple word what is the best way to manage to those files ?

If required I can share screenshots of created files as well.

Version of Realm and Tooling

Realm JS SDK Version: 2.20.0 (NPM module realm)
Node or React Native: Node
Client OS & Version: Ubuntu 16.04.1 LTS

(Kenneth Geisshirt) #2

You can free the unused spaced by calling Realm.compact(). In your case, you might have to close the Realm periodically, compact it and open it again.

(Ahsan Ali) #3

Thanks for reply @kneth.

Can you give me an example when exactly I have to use Realm.compact() ? And what exactly it will do. Will it delete those unused files ? And what should I do with the current 17GB files?

(Kenneth Geisshirt) #4

You can do something like:

let config = { ... };
let realm = new Realm(config);

An alternative is to add it to the configuration:

let config = { ...
  shouldCompactOnLaunch: (totalSize, usedSize) => { return totalSize > 2*usedSize; }
let realm = new Realm.compact(config);

Compacting will never delete files but will remove some unused space in the Realm files (think of it as garbage collection).

(Ahsan Ali) #5

Thankyou @kneth

Can you share a github repo or something with proper implementation of Realm cloud with nodejs express API server. I will be grateful to you.

(Kenneth Geisshirt) #6

Unfortunately we don’t have such a demo app.