Skip to main content

Posts

Showing posts from March, 2019

What are some best practices for reducing memory usage in C?

Thiếu memory khi lập trình Arduino và cách giải quyết. Lacking memory with Arduino program. Đây là một số gợi ý để giải quyết nếu bạn đã từng thấy warning dưới: Have you ever seen any below warning? - Low memory available, stability problems may occur. - Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing your footprint. If the answer is YES, i would like to suggest some solutions for saving memory in this articles. Các nguyên nhân: Some root causes: 1. Khai báo biến local tràn lan. 2. Dùng hàm lcd.print or serial.print tùy tiện. 3. Cấp phát động tùy tiện, ko tính toán kỹ lưỡng số lượng phần từ trong mảng cần dùng. .... Một số gợi ý để tiết kiệm memory  Some suggestions to save memory. - Sử dụng một số kỹ thuật như #pragma pack(), union, bit field, cấp phát động.             Using some C technique #pragma pack(), union, bit field, dynamic memory allocation. - Sử dụng con trỏ mộ