NativeScript / NativeScript/ios
interop.Reference returns undefined value
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 150
- Fork
- 43
- Merge medio
- 3g 10h
- PR unite (30g)
- 22
Descrizione
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;
}
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo il comportamento segnalato relativo a interop.Reference, vm_statistics64, vm_statistics, host_statistics64 e host_statistics su NativeScript iOS 8.1. Confronta i dati vmStat allocati con il valore esposto tramite vmStatRef.value.free_count. Il lavoro è completato quando viene identificato il motivo per cui il campo restituito è undefined e viene confermato un risultato funzionante della memoria libera sulla piattaforma indicata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- ios, typescript
- Ambito
- mobile-dev, operating-systems
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100