A react-native module to get device RAM
npm install react-native-ram
yarn add react-native-ram
import { getAllRamInfo } from "react-native-ram";
React.useEffect(()=>{
getAllRamInfo().then(( ramInfo )=> console.log(ramInfo))
},[])
#### OR use async/await
const getRam=async()=>{
const ramInfo = await getAllRamInfo();
console.log(ramInfo)
}
// ...result example in MB and %
{
"appUsedMemory": 12.637718200683594,
"percentageUsed": 48.736824388734746,
"usedMemory": 2726.0390625,
"availableMemory": 2867.34765625,
"totalMemory": 5593.38671875,
"percentageAvailable": 51.263175611265254
}
Method | Return Type | iOS | Android |
---|---|---|---|
getAllRamInfo() | Promise<RamState> |
✅ | ✅ |
getTotalRam() | Promise<number> |
✅ | ✅ |
getUsedRam() | Promise<number> |
✅ | ✅ |
getAvailableRam() | Promise<number> |
✅ | ✅ |
getPercentageUsed() | Promise<number> |
✅ | ✅ |
getPercentageAvailable() | Promise<number> |
✅ | ✅ |
getAppRamUsed() | Promise<number> |
❌ | ✅ |
interface RamState {
percentageAvailable: number;
percentageUsed: number;
totalMemory: number;
availableMemory: number;
usedMemory: number;
appUsedMemory?: number;
}
MIT