import uos
import gc
def get_storage_usage():
total_bytes = uos.statvfs('/')[0] # Total bytes in the filesystem
free_bytes = uos.statvfs('/')[4] # Free bytes in the filesystem
used_bytes = total_bytes - free_bytes
return total_bytes, used_bytes, free_bytes
def print_storage_usage():
total, used, free = get_storage_usage()
print("Total space: {} bytes".format(total))
print("Used space: {} bytes".format(used))
print("Free space: {} bytes".format(free))
# Example usage:
print("Initial storage usage:")
print_storage_usage()
# Perform some operations that might affect storage usage
# For example, create some variables, files, etc.
# Trigger garbage collection to free up memory if needed
gc.collect()
print("\nAfter operations:")
print_storage_usage()