I created 9 python scripts that I run as cron jobs.
When I run them on a VirtualBox virtual machine running Ubuntu Server 20.04 with 512MB of RAM with a single processor, everything runs smoothly and only a reasonable amount of memory is used by each job (the virtual machine is hosted on a Windows 10 physical machine).
When I try to run the same scripts on a Raspberry Pi Zero 2 running Ubuntu Server 20.04.5 with 512MB of RAM, each job consumes a lot of memory. I was not able to run more than 3 out of the 9 jobs concurrently without the Pi becoming inaccessible by SSH because all the available memory is being consumed by the 3 jobs. CPU-wise, everything seems fine.
Is there a way to optimize python, the scripts, or the Pi to get performance similar to the ones on the virtual machine?
Any help would be greatly appreciated.