Is there a way of checking the size of a file which has been read in? I am specifically trying to figure out the in-memory size of a shapefile read in by the maptools
library:
df = readShapeSpatial("/path/file.shp")
One way to get an estimate of an object's size in Java is to use getObjectSize(Object) method of the Instrumentation interface introduced in Java 5. As we could see in Javadoc documentation, the method provides “implementation-specific approximation” of the specified object's size.
Get file size in java using FileChannel class We can use FileChannel size() method to get file size in bytes.
Use os.path.getsize() function Use the os. path. getsize('file_path') function to check the file size. Pass the file name or file path to this function as an argument.
The size of object of a class depends on the no. of bytes occupied by the data members of the class. }; The object of class student will occupy space of 8 bytes.
object.size(df) ..................................
See ?object.size
:
a <- runif(1e6)
object.size(a)
print(object.size(a), units="Mb")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With