If, after following all those tips, you still have issues with RAM and CPU, then probably it’s mainly because your software is absolutely also hefty, in addition to a Raspberry Pi isn't the proper Software for your task. In cases like this, you should check out different embedded board, like https://www.mirobot.ai/