NativeScript / NativeScript/ios
interop.Reference returns undefined value
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 150
- フォーク
- 43
- 平均マージ
- 3日 10時間
- マージ済み PR(30日)
- 22
説明
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;
}
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、NativeScript iOS 8.1 で interop.Reference、vm_statistics64、vm_statistics、host_statistics64、host_statistics に関して報告された動作を再現します。割り当てられた vmStat データと、vmStatRef.value.free_count を通じて公開される値を比較します。返されたフィールドが undefined になる理由を特定し、報告されたプラットフォームで機能する空きメモリの結果を確認できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- ios, typescript
- 領域
- mobile-dev, operating-systems
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100