aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcommon/llmemory.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:55 -0500
committerJacek Antonelli2008-08-15 23:45:55 -0500
commit9063e60aefe54f7c45aaa8cb24e8998b2c7343ab (patch)
tree1c8235465701c910a5d76448ddc8eb1f14457ebc /linden/indra/llcommon/llmemory.cpp
parentSecond Life viewer sources 1.20.9 (diff)
downloadmeta-impy-9063e60aefe54f7c45aaa8cb24e8998b2c7343ab.zip
meta-impy-9063e60aefe54f7c45aaa8cb24e8998b2c7343ab.tar.gz
meta-impy-9063e60aefe54f7c45aaa8cb24e8998b2c7343ab.tar.bz2
meta-impy-9063e60aefe54f7c45aaa8cb24e8998b2c7343ab.tar.xz
Second Life viewer sources 1.20.10
Diffstat (limited to 'linden/indra/llcommon/llmemory.cpp')
-rw-r--r--linden/indra/llcommon/llmemory.cpp88
1 files changed, 28 insertions, 60 deletions
diff --git a/linden/indra/llcommon/llmemory.cpp b/linden/indra/llcommon/llmemory.cpp
index 8fa324f..9b6f893 100644
--- a/linden/indra/llcommon/llmemory.cpp
+++ b/linden/indra/llcommon/llmemory.cpp
@@ -36,12 +36,8 @@
36# include <psapi.h> 36# include <psapi.h>
37#elif defined(LL_DARWIN) 37#elif defined(LL_DARWIN)
38# include <sys/types.h> 38# include <sys/types.h>
39# include <sys/sysctl.h>
40# include <mach/task.h> 39# include <mach/task.h>
41# include <mach/vm_map.h>
42# include <mach/mach_init.h> 40# include <mach/mach_init.h>
43# include <mach/vm_region.h>
44# include <mach/mach_port.h>
45#elif defined(LL_LINUX) 41#elif defined(LL_LINUX)
46# include <unistd.h> 42# include <unistd.h>
47#endif 43#endif
@@ -314,13 +310,18 @@ U64 getCurrentRSS()
314 310
315#elif defined(LL_DARWIN) 311#elif defined(LL_DARWIN)
316 312
317// This can cause bad stalls! Replace with fast version 313/*
318 314 The API used here is not capable of dealing with 64-bit memory sizes, but is available before 10.4.
319// static U32 getPageSize() 315
320// { 316 Once we start requiring 10.4, we can use the updated API, which looks like this:
321// int ctl[2] = { CTL_HW, HW_PAGESIZE }; 317
322// int page_size; 318 task_basic_info_64_data_t basicInfo;
323// size_t size = sizeof(page_size); 319 mach_msg_type_number_t basicInfoCount = TASK_BASIC_INFO_64_COUNT;
320 if (task_info(mach_task_self(), TASK_BASIC_INFO_64, (task_info_t)&basicInfo, &basicInfoCount) == KERN_SUCCESS)
321
322 Of course, this doesn't gain us anything unless we start building the viewer as a 64-bit executable, since that's the only way
323 for our memory allocation to exceed 2^32.
324*/
324 325
325// if (sysctl(ctl, 2, &page_size, &size, NULL, 0) == -1) 326// if (sysctl(ctl, 2, &page_size, &size, NULL, 0) == -1)
326// { 327// {
@@ -333,58 +334,25 @@ U64 getCurrentRSS()
333 334
334U64 getCurrentRSS() 335U64 getCurrentRSS()
335{ 336{
336 // Stalls!!! 337 U64 residentSize = 0;
337
338// task_t task = mach_task_self();
339// vm_address_t addr = VM_MIN_ADDRESS;
340// vm_size_t size = 0;
341// U64 residentPages = 0;
342 338
343// while (true) 339 task_basic_info_data_t basicInfo;
344// { 340 mach_msg_type_number_t basicInfoCount = TASK_BASIC_INFO_COUNT;
345// mach_msg_type_number_t bcount = VM_REGION_BASIC_INFO_COUNT; 341 if (task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&basicInfo, &basicInfoCount) == KERN_SUCCESS)
346// vm_region_basic_info binfo; 342 {
347// mach_port_t bobj; 343 residentSize = basicInfo.resident_size;
348// kern_return_t ret;
349
350// addr += size;
351
352// ret = vm_region(task, &addr, &size, VM_REGION_BASIC_INFO,
353// (vm_region_info_t) &binfo, &bcount, &bobj);
354
355// if (ret != KERN_SUCCESS)
356// {
357// break;
358// }
359
360// if (bobj != MACH_PORT_NULL)
361// {
362// mach_port_deallocate(task, bobj);
363// }
364
365// mach_msg_type_number_t ecount = VM_REGION_EXTENDED_INFO_COUNT;
366// vm_region_extended_info einfo;
367// mach_port_t eobj;
368
369// ret = vm_region(task, &addr, &size, VM_REGION_EXTENDED_INFO,
370// (vm_region_info_t) &einfo, &ecount, &eobj);
371
372// if (ret != KERN_SUCCESS)
373// {
374// llwarns << "vm_region failed" << llendl;
375// return 0;
376// }
377
378// if (eobj != MACH_PORT_NULL)
379// {
380// mach_port_deallocate(task, eobj);
381// }
382 344
383// residentPages += einfo.pages_resident; 345 // If we ever wanted it, the process virtual size is also available as:
384// } 346 // virtualSize = basicInfo.virtual_size;
347
348// llinfos << "resident size is " << residentSize << llendl;
349 }
350 else
351 {
352 llwarns << "task_info failed" << llendl;
353 }
385 354
386// return residentPages * getPageSize(); 355 return residentSize;
387 return 0;
388} 356}
389 357
390#elif defined(LL_LINUX) 358#elif defined(LL_LINUX)