What are the core differences between microcontrollers and microprocessors, and how do you optimize memory usage on a resource-constrained device?