// Build a combined meminfo from available heaps // free block max size is the single largest free block // other fields are total, or zero where it doesn't make sense to combine void GetCombinedMemInfo(cam_meminfo *camera_meminfo) { // get system meminfo, should always be available GetMemInfo(camera_meminfo); // some fields are set to -1 for vxworks cams #if !defined(CAM_DRYOS) camera_meminfo->allocated_peak = 0; camera_meminfo->total_size = 0; #ifdef CAM_NO_MEMPARTINFO // a more useful base value than 0 camera_meminfo->free_size = camera_meminfo->free_block_max_size; camera_meminfo->free_block_count = 0; camera_meminfo->allocated_size = 0; camera_meminfo->allocated_count = 0; #endif #endif // these don't make sense to combine camera_meminfo->start_address = camera_meminfo->end_address = 0; cam_meminfo m; if(GetARamInfo(&m)) { combine_meminfo(camera_meminfo,&m); } if(GetExMemInfo(&m)) { combine_meminfo(camera_meminfo,&m); } }
/* * logMemManInfo */ static void logMemManInfo( DWORD procid ) { MemByType imageinfo; MemInfo meminfo; SYSTEM_INFO sysinfo; DWORD i; logPrintf( STR_VIRTUAL_MEM_INFO ); GetSystemInfo( &sysinfo ); logPrintf( STR_VIRTUAL_PAGE_SIZE, INDENT, "", sysinfo.dwPageSize, sysinfo.dwPageSize / 1024 ); if( GetMemInfo( procid, &meminfo ) ) { logPrintf( STR_RESERVED_MEM, INDENT, "" ); logMemManClass( &meminfo.res ); logPrintf( STR_COMMITTED_MEM, INDENT, "" ); logMemManClass( &meminfo.mapped ); logPrintf( STR_IMAGE_ADDR_SPACE_FOR, INDENT, "", TOTAL_MEM_STR ); logMemManClass( &meminfo.image ); for( i=0; i < meminfo.modcnt; i++ ) { logPrintf( STR_IMAGE_ADDR_SPACE_FOR, INDENT, "", meminfo.modlist[i] ); if( GetImageMemInfo( procid, meminfo.modlist[i], &imageinfo ) ) { logMemManClass( &imageinfo ); } else { logPrintf( STR_NOT_AVAILABLE, 2 * INDENT, "" ); } } FreeModuleList( meminfo.modlist, meminfo.modcnt ); } else { logPrintf( STR_NOT_AVAILABLE, INDENT, "" ); } }
void gui_module_draw() { int idx, showidx; if (modinspect_redraw) { draw_filled_rect(0, 0, camera_screen.width-1, camera_screen.height-1, MAKE_COLOR(SCREEN_COLOR, SCREEN_COLOR)); draw_txt_string(5, 0, "*** Module Inspector ***", MAKE_COLOR(SCREEN_COLOR, COLOR_WHITE)); draw_txt_string(0, 2, "Idx Name Addr Size", MAKE_COLOR(SCREEN_COLOR, COLOR_WHITE)); showidx=0; for ( idx=0; idx<20; idx++) { struct flat_hdr* flat = module_get_adr(idx); if (flat==0) continue; char namebuf[12]; memcpy(namebuf,flat->modulename,11); namebuf[11]=0; char txt[50]; sprintf(txt,"%02d: %-12s %08x - %d bytes", idx, namebuf, (unsigned)flat, flat->reloc_start); draw_txt_string(0, 3+showidx, txt, MAKE_COLOR(SCREEN_COLOR, COLOR_WHITE)); showidx++; } // sprintf(buf, lang_str(LANG_MSG_MEMORY_INFO_TEXT), core_get_free_memory(), MEMISOSIZE, &_start, &_end); // sprintf(buf,"MEM %08x-%08x - %d free",&_start, &_end,core_get_free_memory()); // sprintf(buf,"--- %-12s %08x - %d","CHDK",&_start, MEMISOSIZE ); draw_txt_string(1, 4+showidx, "SET-redraw, DISP-unload_all, MENU-exit", MAKE_COLOR(SCREEN_COLOR, COLOR_WHITE)); cam_meminfo meminfo; // Display Canon heap memory info // amount of data displayed may vary depending on GetMemInfo implementation memset(&meminfo,0,sizeof(meminfo)); GetMemInfo(&meminfo); gui_mem_info("MEM", &meminfo, showidx); showidx += 3; // Display EXMEM memory info (only if enabled) memset(&meminfo,0,sizeof(meminfo)); if (GetExMemInfo(&meminfo)) { gui_mem_info("EXMEM", &meminfo, showidx); } } modinspect_redraw = 0; }
int core_get_free_memory() { cam_meminfo camera_meminfo; #if defined(OPT_EXMEM_MALLOC) && !defined(OPT_EXMEM_TESTING) // If using the exmem / suba memory allocation system then don't need // to try allocating memory to find out how much is available // Call function to scan free list for the largest free block available. GetExMemInfo(&camera_meminfo); #else // Call function to fill memory info structure and return size of largest free block // If implemented this will use firmware function, otherwise it will calculate largest // free block GetMemInfo(&camera_meminfo); #endif return camera_meminfo.free_block_max_size; }
void * __restrict FastAlloc::_Allocate(size_t dwSize) { OSEnterMutex(hAllocationMutex); //assert(dwSize); if(!dwSize) dwSize = 1; LPVOID lpMemory; Pool *pool; if(dwSize < 0x8001) { MemInfo *meminfo = GetMemInfo(dwSize); if(!meminfo->nextFree) //no pools have been created for this section { lpMemory = OSVirtualAlloc(0x10000); if (!lpMemory) DumpError(TEXT("Out of memory while trying to allocate %d bytes at %p"), dwSize, ReturnAddress()); Pool *&poollist = PoolList[PtrTo32(lpMemory)>>24]; if(!poollist) { poollist = (Pool*)OSVirtualAlloc(sizeof(Pool)*256); if (!poollist) DumpError(TEXT("Out of memory while trying to allocate %d bytes at %p"), dwSize, ReturnAddress()); zero(poollist, sizeof(Pool)*256); } pool = &poollist[(PtrTo32(lpMemory)>>16)&0xFF]; pool->lpMem = lpMemory; pool->bytesTotal = 0x10000; pool->meminfo = meminfo; pool->firstFreeMem = (FreeMemInfo*)lpMemory; pool->lastFreeMem = (FreeMemInfo*)lpMemory; meminfo->nextFree = (FreeMemInfo*)lpMemory; meminfo->nextFree->num = meminfo->maxBlocks; meminfo->nextFree->lpPool = pool; meminfo->nextFree->lpPrev = meminfo->nextFree->lpNext = NULL; }
// Get the information UINT NtGetInfo(NAT *n, RPC_NAT_INFO *t) { OS_INFO *info; FreeRpcNatInfo(t); Zero(t, sizeof(RPC_NAT_INFO)); StrCpy(t->NatProductName, sizeof(t->NatProductName), CEDAR_ROUTER_STR); StrCpy(t->NatVersionString, sizeof(t->NatVersionString), n->Cedar->VerString); StrCpy(t->NatBuildInfoString, sizeof(t->NatBuildInfoString), n->Cedar->BuildInfo); t->NatVerInt = n->Cedar->Build; t->NatBuildInt = n->Cedar->Build; GetMachineName(t->NatHostName, sizeof(t->NatHostName)); info = GetOsInfo(); CopyOsInfo(&t->OsInfo, info); GetMemInfo(&t->MemInfo); return ERR_NO_ERROR; }
std::string CSysInfo::GetAllInfo (void) { struct sInfo { map<string, string> * pMap; string Part; }; sInfo Infos[ ] = { {&m_mapCPU , "CPU" }, {&m_mapOS , "OS" }, {&m_mapVideo, "Video" }, {&m_mapDisc , "Disk" }, {&m_mapMem , "Memory"} }; std::map<string, string>::iterator im; GetCpuInfo (); GetDiskInfo (); GetOSInfo (); GetVideoInfo (); GetMemInfo (); string strInfo; for(int i = 0; i < sizeof (Infos) / sizeof (sInfo); i++) { strInfo += "[ "; strInfo += Infos[ i ].Part + " ]\n"; for(im = Infos[ i ].pMap->begin (); im != Infos[ i ].pMap->end (); im++) { strInfo += im->first; strInfo += " : "; strInfo += im->second; strInfo += "\n"; } } return strInfo; }
/*==================================================================== * 函数名 : vGenRegTermMsg * 功能 : 生成终端注册消息 * 算法实现 : * 参数说明 : * nIdx 标识是哪个的base * 返回值说明: 成功 生成的json字符串 * 失败 NULL * ---------------------------------------------------------------------- * 修改记录: * 日 期 版本 修改人 走读人 修改记录 * 2015/1/13 v1.0 YLI 创建 * ====================================================================*/ json_t *vGenRegTermMsg(int nIdx) { json_t *root; json_t *mt_info; json_t *netinfo; json_t *aps_addr; json_t *jt; const char *key; json_t *value; int n,size; char saCfgPath[L_PATH_MAX_LEN]; char tmp[100]; root = json_object(); memset(tmp,0x00,sizeof tmp); memset(saCfgPath,0x00,sizeof saCfgPath); srand((unsigned)time(NULL)); //set eventid if (json_object_set(root,"eventid", json_string("EV_REG_REQ")) == FAILUER) { json_decref(root); vLogErr("eventid set error!!!"); return NULL; } //devid n = rand() % (S_RAND_RANG + _gstrpPid[nIdx].nTermCount); sprintf(tmp,"1.2.%02d",n); if (json_object_set(root,"devid", json_string(tmp)) == FAILUER) { json_decref(root); vLogErr("devid set error!!!"); return NULL; } //devtype if(getenv("APP_PROFILE_PATH") == NULL) { json_decref(root); vLogErr("devtypes config file path error,please check evn value!!!"); return NULL; } strcpy(saCfgPath,getenv("APP_PROFILE_PATH")); strcat(saCfgPath,"/devtypes.json"); jt = tPflGetJsonObj(saCfgPath,K_DEVTYPE_KEY); if (jt == NULL) { json_decref(root); vLogErr("devtypes file open error,please check devtypes.json is exist!!!"); return NULL; } if (json_is_array(jt)) { size = json_array_size(jt); n = rand()%size; if (json_object_set(root,"devtype", json_array_get(jt,n)) == FAILUER) { json_decref(root); vLogErr("devtype set error!!!"); return NULL; } } /*mt_info*/ mt_info = json_object(); //devver if (json_object_set(mt_info,"devver", json_string("123")) == FAILUER) { json_decref(root); vLogErr("devver set error!!!"); return NULL; } //devname json_object_set(mt_info,"devname",json_string("truelink")); //netinfo netinfo = json_object(); json_object_set(netinfo,"ip", json_string(_gstrpShm->rc.nSrvIP)); json_object_set(netinfo,"dns", json_string("172.16.0.65")); json_object_set(mt_info,"netinfo",netinfo); //aps_addr aps_addr = json_object(); json_object_set(aps_addr,"domain", json_string("fdaf")); json_object_set(aps_addr,"ip", json_string(_gstrpShm->rc.nSrvIP)); json_object_set(mt_info,"aps_addr",aps_addr); //oem json_object_set(mt_info,"oem",json_string("dfd")); //os json_object_set(mt_info,"os",json_string("Centos 6.4")); //cpu_num json_object_set(mt_info,"cpu_num",json_integer(4)); //cpu_type //cpu_freq json_decref(jt); jt = GetCpuInfo(); json_object_foreach(jt,key,value) { if(strncmp(key,"cpuMHz",6) == 0) { json_object_set(mt_info,"cpu_freq",value); } if (strncmp(key,"modelname",9) == 0) { json_object_set(mt_info,"cpu_type",value); } } json_decref(jt); jt = GetMemInfo(); //memory json_object_foreach(jt,key,value) { if(strncmp(key,"MemTotal",8) == 0) { json_object_set(mt_info,"memory",value); } } json_object_set(root,"mt_info",mt_info); json_decref(mt_info); return root; }
int main(int argc, char **argv) { if( argc < 2) { std::cout << SYNTAX << std::endl; return 1; } std::vector<bool> FindLowest; ALGO SelectedAlgo = DEPTH; bool ComputeLastNode = true; bool HasLabels = false; long NumArg = 0; while( ++NumArg < argc - 1) { if( strcmp( argv[NumArg], "-s") == 0) { if( ++NumArg == argc - 1) { std::cout << SYNTAX << std::endl; return 1; } for( unsigned long j = 0; j < strlen( argv[NumArg]); j++) switch( argv[NumArg][j]) { case 'l': FindLowest.push_back(true); break; case 'u': FindLowest.push_back(false); break; default : std::cout << SYNTAX << std::endl; return 1; } } else if( strcmp( argv[NumArg], "-a") == 0) { if( ++NumArg == argc - 1) { std::cout << SYNTAX << std::endl; return 1; } if( strcmp( argv[NumArg], "depth") == 0) SelectedAlgo = DEPTH; else if( strcmp( argv[NumArg], "breadth") == 0) SelectedAlgo = BREADTH; else if( strcmp( argv[NumArg], "br_dom") == 0) SelectedAlgo = BR_DOM; else { std::cout << SYNTAX << std::endl; return 1; } } else if( strcmp( argv[NumArg], "-nolast") == 0) { ComputeLastNode = false; } else if( strcmp( argv[NumArg], "-label") == 0) { HasLabels = true; } else { std::cout << SYNTAX << std::endl; return 1; } } if( strcmp( argv[NumArg], "-h") == 0 || strcmp( argv[NumArg], "--help") == 0) { std::cout << SYNTAX << std::endl; return 1; } double* matrice = 0; long NombrePoints = 0; long NombreDimensions = 0; std::vector<std::string>* Labels = 0; if( HasLabels) Labels = new std::vector<std::string>; if( ! ParseFileIntoMatrix( argv[NumArg], FindLowest.size(), matrice, NombrePoints, NombreDimensions, Labels)) { std::cout << "Error in data set parsing" << std::endl; return 1; } if( FindLowest.size() == 0) for( int j = 0; j < NombreDimensions; j++) FindLowest.push_back(true); ArbreCube bouleau( matrice, FindLowest, NombrePoints, NombreDimensions); // we start creating the result filename here to use the switch once std::string FichierResultat( argv[NumArg]); std::cout << "Selected algorithm "; switch( SelectedAlgo) { case DEPTH: if( ComputeLastNode) { std::cout << "Orion-Clos: Depth with last node first" << std::endl; FichierResultat += ".del."; } else { std::cout << "Depth" << std::endl; FichierResultat += ".dep."; } bouleau.DepthAlgo(ComputeLastNode); std::cout << "Processed nodes: " << bouleau.GetNbProcessedNodes() << std::endl; std::cout << "Closure nodes: " << bouleau.GetNbClos() << "/"; std::cout << (1 << NombreDimensions) - 1 << std::endl; std::cout << "Skyline points found directly / by BNL: " << bouleau.GetNbSkylineFoundDirectly(); std::cout << "/" << bouleau.GetNbSkylineFoundByBNL() << std::endl; break; case BREADTH: std::cout << "Orion: Breadth" << std::endl; bouleau.BreadthAlgo(false); FichierResultat += ".bre."; break; case BR_DOM: std::cout << "Orion-Tail: Breadth with domains" << std::endl; bouleau.BreadthAlgo(true); FichierResultat += ".brd."; break; } std::cout << "Type I nodes: " << bouleau.GetNbType1() << "/" << (1 << NombreDimensions) - 1 << std::endl; ///////////////////////////////////////////////////////////////////////////////////////// // Stat of the day std::cout << "Peak memory usage: " << GetMemInfo() << std::endl; #ifndef BENCH ///////////////////////////////////////////////////////////////////////////////////////// // Storing result somewhere OutputResult( bouleau, FindLowest, SelectedAlgo, FichierResultat, Labels); #endif // BENCH delete[] matrice; return 0; }