Removed unnecessary comments
This commit is contained in:
@@ -30,52 +30,44 @@ class MicroPythonDiagnostics:
|
||||
gc.disable()
|
||||
gc.threshold(5000)
|
||||
|
||||
total_mem = 255616 # Based on your previous mem_info
|
||||
total_mem = 255616
|
||||
bytes_per_hash = 3000
|
||||
|
||||
print("Memory Monitor: [# = Used] [. = Free]")
|
||||
print("-" * (total_mem // bytes_per_hash))
|
||||
|
||||
for i in range(500):
|
||||
# Creating garbage to simulate robot logic/sensors
|
||||
_ = bytearray(300)
|
||||
|
||||
# Only print every 25 iterations to prevent terminal spam
|
||||
if i % 25 == 0:
|
||||
used = gc.mem_alloc()
|
||||
free = gc.mem_free()
|
||||
|
||||
# Calculate how many hashes and dots to draw
|
||||
hashes = used // bytes_per_hash
|
||||
dots = free // bytes_per_hash
|
||||
|
||||
# Print the visual bar with the iteration number
|
||||
print(f"{i:03d}: [{'#' * hashes}{'.' * dots}] {free} bytes free")
|
||||
final_disabled_free = gc.mem_free()
|
||||
input("Enabling garbage collection. The amount of used memory should stay relatively low. Press Enter to begin:")
|
||||
gc.enable()
|
||||
gc.threshold(5000)
|
||||
|
||||
total_mem = 255616 # Based on your previous mem_info
|
||||
total_mem = 255616
|
||||
bytes_per_hash = 3000
|
||||
|
||||
print("Memory Monitor: [# = Used] [. = Free]")
|
||||
print("-" * (total_mem // bytes_per_hash))
|
||||
|
||||
for i in range(500):
|
||||
# Creating garbage to simulate robot logic/sensors
|
||||
_ = bytearray(300)
|
||||
|
||||
# Only print every 25 iterations to prevent terminal spam
|
||||
if i % 25 == 0:
|
||||
used = gc.mem_alloc()
|
||||
free = gc.mem_free()
|
||||
|
||||
# Calculate how many hashes and dots to draw
|
||||
hashes = used // bytes_per_hash
|
||||
dots = free // bytes_per_hash
|
||||
|
||||
# Print the visual bar with the iteration number
|
||||
print(f"{i:03d}: [{'#' * hashes}{'.' * dots}] {free} bytes free")
|
||||
|
||||
final_enabled_free = gc.mem_free()
|
||||
@@ -111,7 +103,6 @@ class MicroPythonDiagnostics:
|
||||
except MemoryError:
|
||||
print("[Hub Diagnostics - MicroPython - Memory] Completed Test 2/5: Heap lock - SUCCESS")
|
||||
self.successfultests += 1
|
||||
# Attempt to add gc to this for memory diagnostics, in addition test machine.soft_reset() and add that first to reset the heap.
|
||||
print("[Hub Diagnostics - MicroPython - Memory] Unlocking the heap:")
|
||||
micropython.heap_unlock()
|
||||
print("[Hub Diagnostics - MicroPython - Memory] Heap was unlocked. Attempting to allocate memory (this should succeed):")
|
||||
|
||||
Reference in New Issue
Block a user