@@ -194,7 +194,9 @@ static native void nativeRegisterCustomType(long store, int entityId, int proper
194194
195195 static native boolean nativeIsObjectBrowserAvailable ();
196196
197- native long nativeSizeOnDisk (long store );
197+ native long nativeDbSize (long store );
198+
199+ native long nativeDbSizeOnDisk (long store );
198200
199201 native long nativeValidate (long store , long pageLimit , boolean checkLeafLevel );
200202
@@ -484,9 +486,31 @@ public static long sysProcStatusKb(String key) {
484486 * The size in bytes occupied by the data file on disk.
485487 *
486488 * @return 0 if the size could not be determined (does not throw unless this store was already closed)
489+ * @deprecated Use {@link #getDbSize()} or {@link #getDbSizeOnDisk()} instead which properly handle in-memory databases.
487490 */
491+ @ Deprecated
488492 public long sizeOnDisk () {
489- return nativeSizeOnDisk (getNativeStore ());
493+ return getDbSize ();
494+ }
495+
496+ /**
497+ * Get the size of this store. For a disk-based store type, this corresponds to the size on disk, and for the
498+ * in-memory store type, this is roughly the used memory bytes occupied by the data.
499+ *
500+ * @return The size in bytes of the database, or 0 if the file does not exist or some error occurred.
501+ */
502+ public long getDbSize () {
503+ return nativeDbSize (getNativeStore ());
504+ }
505+
506+ /**
507+ * The size in bytes occupied by the database on disk (if any).
508+ *
509+ * @return The size in bytes of the database on disk, or 0 if the underlying database is in-memory only
510+ * or the size could not be determined.
511+ */
512+ public long getDbSizeOnDisk () {
513+ return nativeDbSizeOnDisk (getNativeStore ());
490514 }
491515
492516 /**
0 commit comments