Home
Support

Knowledge Base

BSPs and drivers
Community resources
Product documentation
Questions?
Contact us

Detect Total Ram in System from Code
 
________________________________________________________________________

Applicable Environment
________________________________________________________________________
  • Topic: Detect Total Ram in System from Code
  • SDP: 6.5.0
  • Target: 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.
________________________________________________________________________


Related Attachments
 None Found





Please contact us with your questions or concerns.