Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@airbnb/node-memwatch",
"description": "Keep an eye on your memory usage, and discover and isolate leaks.",
"version": "2.0.0",
"version": "2.0.1",
"author": "Lloyd Hilaiel (http://lloyd.io)",
"engines": {
"node": ">= 10.0"
Expand Down
15 changes: 14 additions & 1 deletion src/memwatch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,26 @@

#include <math.h> // for pow
#include <time.h> // for time
#include <sys/time.h>
// #include <sys/time.h>
#include <chrono> // use chrono instead of sys/time.h

using namespace v8;
using namespace node;

Local<Object> g_context;

// define gettimeofday which uses chrono, earlier it was defined in header sys/time.h which is now deprecated
int gettimeofday(struct timeval* tp, struct timezone* tzp) {
namespace sc = std::chrono;
sc::system_clock::duration d = sc::system_clock::now().time_since_epoch();
sc::seconds s = sc::duration_cast<sc::seconds>(d);
tp->tv_sec = s.count();
tp->tv_usec = sc::duration_cast<sc::microseconds>(d - s).count();

return 0;
}


class UponGCCallback : public Nan::AsyncResource {
public:
UponGCCallback(v8::Local<v8::Function> callback_) : Nan::AsyncResource("memwatch:upon_gc") {
Expand Down