JulStrat/LibYxml

RAM requirement for parsing large XML file on STM32

Closed this issue · 3 comments

I'm using this library for parsing XML file on STM32, as of now my file size is ~3.8kB( it can grow in future), I've statically allocated 4k memory for stack buffer. I don't want to use malloc as mentioned in ReadMe
`#define BUFSIZE 4096

*void buf = malloc(BUFSIZE);
instead, used static memory allocation
yxml_t x;
yxml_init(&x, buf, BUFSIZE);`

my questions is, if my file size grows beyond 4kb then yxml_parse function will not be able to parse complete file as reference in stack to YXMLS_pi may be lost after 4kb? please advise.
thanks,

Hi, @Newfatuser !
Sorry for delay.

You can estimate BUFSIZE - 1+XML_DEPTH*(ELEMENT_NAME_LEN+1)+MAX(PI_NAME_LEN, PROPERTY_NAME_LEN)+1
BUFSIZE - 8KiB would be enough for most cases even for big XML files.

Buffer holds only path from XML root node to leaf node, not complete XML file.
So just try parse big XML file(s) beyond 4KiB (8, 16, 32...) with same structure.

Check also code examples here - https://github.com/JulStrat/LibYxml#character-data

Best regards.

Thanks for reply, I'll try and let you know.

BTW I will add more practical example (parsing XML file from SD card) next week
UPDATE Added examples -> file
sat.xml 504KB XML file parsed using 64 byte buffer.