1 #import "ITVirtualMemoryInfo.h"
5 @interface ITVirtualMemoryInfo (Private)
6 - (BOOL)refreshStats:(struct vm_statistics *)myStat;
9 @implementation ITVirtualMemoryInfo
12 if ( ( self = [super init] ) ) {
13 if ([self refreshStats:&stat] == NO) {
25 [self refreshStats:&stat];
26 return stat.free_count;
30 [self refreshStats:&stat];
31 return stat.active_count;
34 - (int)inactivePages {
35 [self refreshStats:&stat];
36 return stat.inactive_count;
40 [self refreshStats:&stat];
41 return stat.wire_count;
45 [self refreshStats:&stat];
49 - (int)copyOnWritePages {
50 [self refreshStats:&stat];
51 return stat.cow_faults;
54 - (int)zeroFilledPages {
55 [self refreshStats:&stat];
56 return stat.zero_fill_count;
59 - (int)reactivatedPages {
60 [self refreshStats:&stat];
61 return stat.reactivations;
65 [self refreshStats:&stat];
70 [self refreshStats:&stat];
75 [self refreshStats:&stat];
80 [self refreshStats:&stat];
84 - (int)hitratePercentage {
85 [self refreshStats:&stat];
86 if ( stat.lookups == 0 ) {
89 return ( ( stat.hits * 100 ) / stat.lookups );
93 - (BOOL)refreshStats:(struct vm_statistics *)myStat {
94 bzero(myStat,sizeof(myStat));
95 mach_port_t myHost = mach_host_self();
96 int count = HOST_VM_INFO_COUNT;
97 ITDebugLog(@"%i",count);
98 int returned = host_statistics(myHost, HOST_VM_INFO, myStat, &count);
99 if ( returned != KERN_SUCCESS ) {
100 ITDebugLog(@"Failed to get Statistics in -refreshStats method of ITVirtualMemoryInfo");
101 ITDebugLog(@"%s",strerror(returned));