From 596cfd4e7dfb208a7dd40ced56626ad6b7b7bbc3 Mon Sep 17 00:00:00 2001 From: Christopher Bowns Date: Sat, 19 Jan 2008 14:38:17 -0500 Subject: [PATCH] one bug to build. --- CPUInfo.m | 1 + CPUMon.taskpaper | 60 ++++++++++++++++++++++++++------------------------------ 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/CPUInfo.m b/CPUInfo.m index 116cbda..f825dba 100644 --- a/CPUInfo.m +++ b/CPUInfo.m @@ -67,6 +67,7 @@ outptr = -1; // set the lastProcessorInfo array so we can get to work when we call refresh: + natural_t numProcessors_nobodyCares = 0U; kern_return_t err = host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, (natural_t *)&numProcessors_nobodyCares, (processor_info_array_t *)&lastProcessorInfo, (mach_msg_type_number_t *)&numLastProcessorInfo); if(err != KERN_SUCCESS) { NSLog(@"%s failed to get cpu statistics", _cmd); diff --git a/CPUMon.taskpaper b/CPUMon.taskpaper index 4e15c7a..ffc0f26 100644 --- a/CPUMon.taskpaper +++ b/CPUMon.taskpaper @@ -1,13 +1,4 @@ CPU Mon: -- memory leak: vm_deallocate the processorInfo array after use: - if(lastProcessorInfo) { - size_t lastProcessorInfoSize = sizeof(integer_t) * numLastProcessorInfo; - vm_deallocate(target_task, (vm_address_t)lastProcessorInfo, lastProcessorInfoSize); - } - - lastProcessorInfo = processorInfo; - numLastProcessorInfo = numProcessorInfo; - - switch the source of the graph from memory info to CPU info: - first test data coming out of cpu info with logs (this might hurt. limit to one sample every 2 sec) - test with xcode debugger to watch array data change. @@ -24,29 +15,6 @@ CPU Mon: - - -- methods needed: - - updateCPUStat: what do we want to accomplish here? - - get current data @done - - retrieve data at last refresh @done - - subtract last from current @done - - init: init the processor usage data: set the first "lastProcessorInfo" array so update is all good to go. - - getCurrentData - - return last data - - getNext: - - run update - - set ptr new data - - update internal ptrs - - - - getPrev - - return one before last? -- variables needed: - - CPUData array - - lastProcessorInfo (for diffs) - - numLastProcessorInfo (to deallocate it) - - two variables to track size, location in array -- notes: need TWO refreshes at init to get current info! Archive: - get it to build @done @project(CPU Mon) - make another pass through the source to take out extraneous references to CPUUsage @done @project(CPU Mon) @@ -54,3 +22,31 @@ Archive: - how to do data update: make a large float array with my usage data in it, use a rolling pointer to update things. store new data from current cpu stats. @done @project(CPU Mon) - is that how the current and last stuff is built? @done @project(CPU Mon) - in other words, I need to pass the pointer by reference so I can modify its value (ie the memory it points to). keep in mind, someone has to clean up after the old memory. @done @project(CPU Mon) +- memory leak: vm_deallocate the processorInfo array after use: @done @project(CPU Mon) +- methods needed: @done @project(CPU Mon) + - updateCPUStat: what do we want to accomplish here? @done @project(CPU Mon) + - get current data @done @project(CPU Mon) + - retrieve data at last refresh @done @project(CPU Mon) + - subtract last from current @done @project(CPU Mon) + - init: init the processor usage data: set the first "lastProcessorInfo" array so update is all good to go. @done @project(CPU Mon) + - getCurrentData @done @project(CPU Mon) + - return last data @done @project(CPU Mon) + - getNext: @done @project(CPU Mon) + - run update @done @project(CPU Mon) + - set ptr new data @done @project(CPU Mon) + - update internal ptrs @done @project(CPU Mon) + - getPrev @done @project(CPU Mon) + - return one before last? @done @project(CPU Mon) +- variables needed: @done @project(CPU Mon) + - CPUData array @done @project(CPU Mon) + - lastProcessorInfo (for diffs) @done @project(CPU Mon) + - numLastProcessorInfo (to deallocate it) @done @project(CPU Mon) + - two variables to track size, location in array @done @project(CPU Mon) +- notes: need TWO refreshes at init to get current info! @done @project(CPU Mon) + if(lastProcessorInfo) { + size_t lastProcessorInfoSize = sizeof(integer_t) * numLastProcessorInfo; + vm_deallocate(target_task, (vm_address_t)lastProcessorInfo, lastProcessorInfoSize); + } + + lastProcessorInfo = processorInfo; + numLastProcessorInfo = numProcessorInfo; -- 2.11.4.GIT