我们经常在优化相机的内存,性能调优或者其相关引起的稳定性流程问题时,需要来针对系统内存大小判断来做camera flow相关客制化修改;
内存检测方法参考如下:
BOOL GetLowMemorystate()
{
std::string s_file = "proc/meminfo";
char buf_file[MEMINFO_FILE_BUFFER_SIZE];
char buf_mem[MEMORY_SIZE_BUFFER];
FILE *F = fopen(s_file.c_str(), "r");
if (F != 0)
{
for(int i = 0; i < MEMAVAILABLE_LINE_IN_FILE; i++)
{
fgets(buf_file, sizeof(buf_file), F);
}
memcpy(buf_mem,&buf_file[17], MEMORY_SIZE_BUFFER);
buf_mem[MEMORY_SIZE_BUFFER - 1] = '\0';
CAMX_LOG_CONFIG(CamxLogGroupHAL, "lowmemory: MemAvailable : %d", atoi(buf_mem));
fclose(F);
if (atoi(buf_mem) < BURST_TRIGGER_MEMORY)
{
return TRUE;
}
}
return FALSE;
}