Detect Total Ram in System from Code ________________________________________________________________________
Applicable Environment
________________________________________________________________________
Topic : Detect Total Ram in System from CodeSDP : 6.5.0Target : Any supported target________________________________________________________________________
Recommendation ________________________________________________________________________
To obtain the total system memory from code you will need to query
the the system page. Here is a simple example on how this can be done.
static uint64_t get_total_mem(void) { char *str = SYSPAGE_ENTRY(strings)->data; struct asinfo_entry *as = SYSPAGE_ENTRY(asinfo); uint64_t total = 0; unsigned num; for(num = _syspage_ptr->asinfo.entry_size / sizeof(*as); num > 0; --num) { if(strcmp(&str[as->name], "ram") == 0) { total += as->end - as->start + 1; } ++as; } return total; }
________________________________________________________________________
NOTE :
This entry has been validated against the SDP version listed above. Use
caution when considering this advice for any other SDP version. For
supported releases, please reach out to QNX Technical Support if you have any questions/concerns.________________________________________________________________________
Please contact us with your questions or concerns.