interop.Reference returns undefined value
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- ios, typescript
调研方向
首先,在 NativeScript iOS 8.1 上复现围绕 interop.Reference、vm_statistics64、vm_statistics、host_statistics64 和 host_statistics 报告的行为。将已分配的 vmStat 数据与通过 vmStatRef.value.free_count 暴露的值进行比较。完成标准是确定返回字段为何为 undefined,并确认在所报告的平台上能够正常获得可用内存结果。
由索引模型根据 Issue 内容生成。
描述
Hi everyone,
I need your help to understand why the vmStatRef.value.free_count in the below code returns undefine value.
I am using NativeScript 8.1. The platform is iOS.
"devDependencies": {
"@nativescript/android": "~8.1.1",
"@nativescript/core": "~8.1.4",
"@nativescript/ios": "~8.1.0",
"@nativescript/types": "~8.1.1",
"@nativescript/webpack": "^3.0.0",
"prompt": "^1.2.0",
"rimraf": "^3.0.2",
"semver": "^7.3.5",
"ts-node": "^10.4.0",
"ts-patch": "^1.4.4",
"tslint": "^6.1.3",
"typescript": "~4.4.4"
}
The git repository is https://github.com/DeepakArora76/nativescript-dna-deviceinfo
Here is a 64-bit implementation
static freeMemory(): number {
const KERN_SUCCESS = 0;
const HOST_VM_INFO = 2;
const hostSize = new interop.Reference(interop.sizeof(vm_statistics64)/interop.sizeof(interop.types.int64));
const hostPort = mach_host_self();
const pageSize = new interop.Reference(0);
host_page_size(hostPort, pageSize);
const vmStat = interop.alloc(interop.sizeof(vm_statistics64));
let freeMem = -1;
if (host_statistics64(hostPort, HOST_VM_INFO, vmStat, hostSize) === KERN_SUCCESS) {
const vmStatRef = new interop.Reference<vm_statistics64>(vm_statistics64, vmStat);
freeMem = vmStatRef.value.free_count * pageSize.value;
}
return freeMem;
}
I also tried vm_statistics instead of vm_statistics64 and that too failed as well!
32-bit implementation
static freeMemory(): number {
const KERN_SUCCESS = 0;
const HOST_VM_INFO = 2;
const hostSize = new interop.Reference(interop.sizeof(vm_statistics)/interop.sizeof(interop.types.int32));
const hostPort = mach_host_self();
const pageSize = new interop.Reference(0);
host_page_size(hostPort, pageSize);
const vmStat = interop.alloc(interop.sizeof(vm_statistics));
let freeMem = -1;
if (host_statistics(hostPort, HOST_VM_INFO, vmStat, hostSize) === KERN_SUCCESS) {
const vmStatRef = new interop.Reference<vm_statistics>(vm_statistics, vmStat);
freeMem = vmStatRef.value.free_count * pageSize.value;
}
return freeMem;
}
- 主要语言
- JavaScript
- 星标
- 150
- 派生
- 43
- 平均合并
- 3 天 10 小时
- 30 天内合并 PR
- 22
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
NativeScript/ios 的其他 Issue
-
难度 5/5 一周以上 新手友好度 38/100
NativeScript/ios#459 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 25/100
NativeScript/ios#445 ·
-
难度 3/5 3-5 天 新手友好度 66/100
NativeScript/ios#414 ·
-
question
难度 4/5 3-5 天 新手友好度 34/100
NativeScript/ios#364 · 2 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
NativeScript/ios#355 ·
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
palladius/rails8-app-on-gcp#145 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
dotenvx/dotenv-vscode#139 ·
-
test-change-proposal
难度 2/5 1-3 小时 新手友好度 65/100
web-platform-tests/interop#1455 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
corsairdev/corsair#1764 ·
-
难度 2/5 1-3 小时 新手友好度 75/100