different memory size



  • Hi,

    I'm running this simple program is two different LoPy

    import gc

    gc.collect()
    print (gc.mem_free())

    I got 65024 in one LoPy and 57488 in another. What explains the difference in memory ?
    Different hardware version, different upgrade ?

    Thanks

    Laurent



  • @ltn22 your are calling this method not on a bare metal system.

    There is an operating system running in the background and on top of it runs python. Each of them needs some memory to run. You can try to disable all radio devices, background tasks and place the your script in main.py to get rid of different timings by typing. But even your chance to see the same amount of free memory is low. There will be always small differences in the state of your LoPys which can result in a different memory usage.

    How well the collect can clean up your unused memory depends on the implementation. You can try to call collect multiple times and wait between the calls. But each additonal (high level) statement may result in a different state of the whole system.

    If you have trouble to get free memory for storing large arrays, there will be another problem. Fragmentation. mem_free may show you enough memory, but most likely this memory will not be available in one huge chunk. There will be a mixture of small and huge blocks depending on what was running before and if the garbage collector is able to move still allocated objects inside the memory.



  • @ltn22
    do you have some files there - especially boot.py or main.py?
    And yes, different firmware can cause different memory consumption.


Log in to reply
 

Pycom on Twitter