Skip to content

Instantly share code, notes, and snippets.

@smockle
Created June 14, 2019 15:00
Show Gist options
  • Save smockle/4b9e52169310a57ac31b401d2275f3eb to your computer and use it in GitHub Desktop.
Save smockle/4b9e52169310a57ac31b401d2275f3eb to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
// @ts-check
const geoip = require('geoip-lite');
function memoryUsageInMegabytes() {
const memoryUsageInBytes = process.memoryUsage();
const memoryUsageInMegabytes = {};
for (const key in memoryUsageInBytes) {
memoryUsageInMegabytes[key] = `${(memoryUsageInBytes[key] / 1000000).toFixed(2)}MB`;
}
return memoryUsageInMegabytes;
}
console.log(memoryUsageInMegabytes());
console.log("For an explanation of these values, see https://nodejs.org/api/process.html#process_process_memoryusage");
#!/usr/bin/env node
// @ts-check
const geoip = require('geoip-ultralight');
function memoryUsageInMegabytes() {
const memoryUsageInBytes = process.memoryUsage();
const memoryUsageInMegabytes = {};
for (const key in memoryUsageInBytes) {
memoryUsageInMegabytes[key] = `${(memoryUsageInBytes[key] / 1000000).toFixed(2)}MB`;
}
return memoryUsageInMegabytes;
}
console.log(memoryUsageInMegabytes());
console.log("For an explanation of these values, see https://nodejs.org/api/process.html#process_process_memoryusage");
@smockle
Copy link
Author

smockle commented Jun 14, 2019

Usage:

npm init --yes
npm install --save geoip-ultralight geoip-lite
node geoip-lite.js
node geoip-ultralight.js

Results:

clay in ~/Developer/geoip
$ node geoip-lite.js
{ rss: '127.45MB',
  heapTotal: '9.68MB',
  heapUsed: '4.64MB',
  external: '107.22MB' }
For an explanation of these values, see https://nodejs.org/api/process.html#process_process_memoryusage
                                                                                                                                                                                                            
clay in ~/Developer/geoip
$ node geoip-ultralight.js
{ rss: '22.52MB',
  heapTotal: '9.68MB',
  heapUsed: '4.35MB',
  external: '2.57MB' }
For an explanation of these values, see https://nodejs.org/api/process.html#process_process_memoryusage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment