Skip to content

Commit b53d3d8

Browse files
Gunnar Kudrjavetsfacebook-github-bot
Gunnar Kudrjavets
authored andcommitted
Fix free page calculations on iOS
Summary: [iOS] [Fixed] - Fix how the amount of free memory is calculated to mimic the logic Apple uses. For example, see https://opensource.apple.com/source/system_cmds/system_cmds-805.250.2/vm_stat.tproj/vm_stat.c.auto.html for how `vm_stat` does it: ``` sspstat("Pages free:", (uint64_t) (vm_stat.free_count - vm_stat.speculative_count)); ``` Reviewed By: shergin Differential Revision: D17671714 fbshipit-source-id: 18ef31e17a0527a9bef7a408922cd687260866db
1 parent 769d518 commit b53d3d8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Libraries/Image/RCTUIImageViewAnimated.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static NSUInteger RCTDeviceFreeMemory() {
3131
if (kern != KERN_SUCCESS) return 0;
3232
kern = host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size);
3333
if (kern != KERN_SUCCESS) return 0;
34-
return vm_stat.free_count * page_size;
34+
return (vm_stat.free_count - vm_stat.speculative_count) * page_size;
3535
}
3636

3737
@interface RCTUIImageViewAnimated () <CALayerDelegate>

0 commit comments

Comments
 (0)