keep RAM overflowing

hello I pretend create a game using arduino due, Im gonna use tft screen 1.8 ( 168 * 120 ) ,the fact is that every sprite on screen will be a bit map ( actually an structure with x, y, w, h, etc ), for what I know is that I cannot draw everything , the question is, how do I know how many sprites to print in screen and how to tract RAM usage when im making collisions, printing, etc...?

pavul:
know how many sprites to print in screen and how to tract RAM usage when im making collisions, printing, etc…?

I don’t know how many sprites you can print :slight_smile: but you have 96 KBytes of contiguous SRAM.

I found this to know the free SRAM:

#include <malloc.h>
//#include <stdlib.h>
//#include <stdio.h>

extern char _end;
extern "C" char *sbrk(int i);
char *ramstart = (char *)0x20070000;
char *ramend = (char *)0x20088000;

void setup() {
  Serial.begin(250000);
  
  char *heapend = sbrk(0);
  register char * stack_ptr asm ("sp");
  struct mallinfo mi = mallinfo();
  printf("\nDynamic ram used: %d\n", mi.uordblks);
  printf("Program static ram used %d\n", &_end - ramstart);
  printf("Stack ram used %d\n\n", ramend - stack_ptr);
  printf("My guess at free mem: %d\n", stack_ptr - heapend + mi.fordblks);
}

void loop() {

}