diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llcommon/llmemory.cpp | 115 |
1 files changed, 60 insertions, 55 deletions
diff --git a/linden/indra/llcommon/llmemory.cpp b/linden/indra/llcommon/llmemory.cpp index 5edeb4b..8fa324f 100644 --- a/linden/indra/llcommon/llmemory.cpp +++ b/linden/indra/llcommon/llmemory.cpp | |||
@@ -314,72 +314,77 @@ U64 getCurrentRSS() | |||
314 | 314 | ||
315 | #elif defined(LL_DARWIN) | 315 | #elif defined(LL_DARWIN) |
316 | 316 | ||
317 | static U32 getPageSize() | 317 | // This can cause bad stalls! Replace with fast version |
318 | { | 318 | |
319 | int ctl[2] = { CTL_HW, HW_PAGESIZE }; | 319 | // static U32 getPageSize() |
320 | int page_size; | 320 | // { |
321 | size_t size = sizeof(page_size); | 321 | // int ctl[2] = { CTL_HW, HW_PAGESIZE }; |
322 | 322 | // int page_size; | |
323 | if (sysctl(ctl, 2, &page_size, &size, NULL, 0) == -1) | 323 | // size_t size = sizeof(page_size); |
324 | { | 324 | |
325 | llwarns << "Couldn't get page size" << llendl; | 325 | // if (sysctl(ctl, 2, &page_size, &size, NULL, 0) == -1) |
326 | return 0; | 326 | // { |
327 | } else { | 327 | // llwarns << "Couldn't get page size" << llendl; |
328 | return page_size; | 328 | // return 0; |
329 | } | 329 | // } else { |
330 | } | 330 | // return page_size; |
331 | // } | ||
332 | // } | ||
331 | 333 | ||
332 | U64 getCurrentRSS() | 334 | U64 getCurrentRSS() |
333 | { | 335 | { |
334 | task_t task = mach_task_self(); | 336 | // Stalls!!! |
335 | vm_address_t addr = VM_MIN_ADDRESS; | 337 | |
336 | vm_size_t size = 0; | 338 | // task_t task = mach_task_self(); |
337 | U64 residentPages = 0; | 339 | // vm_address_t addr = VM_MIN_ADDRESS; |
338 | 340 | // vm_size_t size = 0; | |
339 | while (true) | 341 | // U64 residentPages = 0; |
340 | { | 342 | |
341 | mach_msg_type_number_t bcount = VM_REGION_BASIC_INFO_COUNT; | 343 | // while (true) |
342 | vm_region_basic_info binfo; | 344 | // { |
343 | mach_port_t bobj; | 345 | // mach_msg_type_number_t bcount = VM_REGION_BASIC_INFO_COUNT; |
344 | kern_return_t ret; | 346 | // vm_region_basic_info binfo; |
347 | // mach_port_t bobj; | ||
348 | // kern_return_t ret; | ||
345 | 349 | ||
346 | addr += size; | 350 | // addr += size; |
347 | 351 | ||
348 | ret = vm_region(task, &addr, &size, VM_REGION_BASIC_INFO, | 352 | // ret = vm_region(task, &addr, &size, VM_REGION_BASIC_INFO, |
349 | (vm_region_info_t) &binfo, &bcount, &bobj); | 353 | // (vm_region_info_t) &binfo, &bcount, &bobj); |
350 | 354 | ||
351 | if (ret != KERN_SUCCESS) | 355 | // if (ret != KERN_SUCCESS) |
352 | { | 356 | // { |
353 | break; | 357 | // break; |
354 | } | 358 | // } |
355 | 359 | ||
356 | if (bobj != MACH_PORT_NULL) | 360 | // if (bobj != MACH_PORT_NULL) |
357 | { | 361 | // { |
358 | mach_port_deallocate(task, bobj); | 362 | // mach_port_deallocate(task, bobj); |
359 | } | 363 | // } |
360 | 364 | ||
361 | mach_msg_type_number_t ecount = VM_REGION_EXTENDED_INFO_COUNT; | 365 | // mach_msg_type_number_t ecount = VM_REGION_EXTENDED_INFO_COUNT; |
362 | vm_region_extended_info einfo; | 366 | // vm_region_extended_info einfo; |
363 | mach_port_t eobj; | 367 | // mach_port_t eobj; |
364 | 368 | ||
365 | ret = vm_region(task, &addr, &size, VM_REGION_EXTENDED_INFO, | 369 | // ret = vm_region(task, &addr, &size, VM_REGION_EXTENDED_INFO, |
366 | (vm_region_info_t) &einfo, &ecount, &eobj); | 370 | // (vm_region_info_t) &einfo, &ecount, &eobj); |
367 | 371 | ||
368 | if (ret != KERN_SUCCESS) | 372 | // if (ret != KERN_SUCCESS) |
369 | { | 373 | // { |
370 | llwarns << "vm_region failed" << llendl; | 374 | // llwarns << "vm_region failed" << llendl; |
371 | return 0; | 375 | // return 0; |
372 | } | 376 | // } |
373 | 377 | ||
374 | if (eobj != MACH_PORT_NULL) | 378 | // if (eobj != MACH_PORT_NULL) |
375 | { | 379 | // { |
376 | mach_port_deallocate(task, eobj); | 380 | // mach_port_deallocate(task, eobj); |
377 | } | 381 | // } |
378 | 382 | ||
379 | residentPages += einfo.pages_resident; | 383 | // residentPages += einfo.pages_resident; |
380 | } | 384 | // } |
381 | 385 | ||
382 | return residentPages * getPageSize(); | 386 | // return residentPages * getPageSize(); |
387 | return 0; | ||
383 | } | 388 | } |
384 | 389 | ||
385 | #elif defined(LL_LINUX) | 390 | #elif defined(LL_LINUX) |