## V8 internals
The hooks to access V8 internals—including GC and statistics—are different across the supported versions of V8, therefore NAN provides its own hooks that call the appropriate V8 methods.
- NAN_GC_CALLBACK()
- Nan::AddGCEpilogueCallback()
- Nan::RemoveGCEpilogueCallback()
- Nan::AddGCPrologueCallback()
- Nan::RemoveGCPrologueCallback()
- Nan::GetHeapStatistics()
- Nan::SetCounterFunction()
- Nan::SetCreateHistogramFunction()
- Nan::SetAddHistogramSampleFunction()
- Nan::IdleNotification()
- Nan::LowMemoryNotification()
- Nan::ContextDisposedNotification()
- Nan::GetInternalFieldPointer()
- Nan::SetInternalFieldPointer()
- Nan::AdjustExternalMemory()
### NAN_GC_CALLBACK(callbackname)
Use `NAN_GC_CALLBACK` to declare your callbacks for `Nan::AddGCPrologueCallback()` and `Nan::AddGCEpilogueCallback()`. Your new method receives the arguments `v8::GCType type` and `v8::GCCallbackFlags flags`.
```c++
static Nan::Persistent callback;
NAN_GC_CALLBACK(gcPrologueCallback) {
v8::Local argv[] = { Nan::New("prologue").ToLocalChecked() };
Nan::MakeCallback(Nan::GetCurrentContext()->Global(), Nan::New(callback), 1, argv);
}
NAN_METHOD(Hook) {
callback.Reset(args[0].As());
Nan::AddGCPrologueCallback(gcPrologueCallback);
info.GetReturnValue().Set(info.Holder());
}
```
### Nan::AddGCEpilogueCallback()
Signature:
```c++
void Nan::AddGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback, v8::GCType gc_type_filter = v8::kGCTypeAll)
```
Calls V8's [`AddGCEpilogueCallback()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#a90d1860babc76059c62514b422f56960).
### Nan::RemoveGCEpilogueCallback()
Signature:
```c++
void Nan::RemoveGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback)
```
Calls V8's [`RemoveGCEpilogueCallback()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#a05c60859fd4b8e96bfcd451281ed6c7c).
### Nan::AddGCPrologueCallback()
Signature:
```c++
void Nan::AddGCPrologueCallback(v8::Isolate::GCPrologueCallback, v8::GCType gc_type_filter callback)
```
Calls V8's [`AddGCPrologueCallback()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#ab4b87b8f9f8e5bf95eba4009357e001f).
### Nan::RemoveGCPrologueCallback()
Signature:
```c++
void Nan::RemoveGCPrologueCallback(v8::Isolate::GCPrologueCallback callback)
```
Calls V8's [`RemoveGCEpilogueCallback()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#a9f6c51932811593f81ff30b949124186).
### Nan::GetHeapStatistics()
Signature:
```c++
void Nan::GetHeapStatistics(v8::HeapStatistics *heap_statistics)
```
Calls V8's [`GetHeapStatistics()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#a5593ac74687b713095c38987e5950b34).
### Nan::SetCounterFunction()
Signature:
```c++
void Nan::SetCounterFunction(v8::CounterLookupCallback cb)
```
Calls V8's [`SetCounterFunction()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#a045d7754e62fa0ec72ae6c259b29af94).
### Nan::SetCreateHistogramFunction()
Signature:
```c++
void Nan::SetCreateHistogramFunction(v8::CreateHistogramCallback cb)
```
Calls V8's [`SetCreateHistogramFunction()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#a542d67e85089cb3f92aadf032f99e732).
### Nan::SetAddHistogramSampleFunction()
Signature:
```c++
void Nan::SetAddHistogramSampleFunction(v8::AddHistogramSampleCallback cb)
```
Calls V8's [`SetAddHistogramSampleFunction()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#aeb420b690bc2c216882d6fdd00ddd3ea).
### Nan::IdleNotification()
Signature:
```c++
void Nan::IdleNotification(v8::HeapStatistics *heap_statistics)
```
Calls V8's [`IdleNotification()` or `IdleNotificationDeadline()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#ad6a2a02657f5425ad460060652a5a118) depending on V8 version.
### Nan::LowMemoryNotification()
Signature:
```c++
void Nan::LowMemoryNotification()
```
Calls V8's [`IdleNotification()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#a24647f61d6b41f69668094bdcd6ea91f).
### Nan::ContextDisposedNotification()
Signature:
```c++
void Nan::ContextDisposedNotification()
```
Calls V8's [`ContextDisposedNotification()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#ad7f5dc559866343fe6cd8db1f134d48b).
### Nan::GetInternalFieldPointer()
Gets a pointer to the internal field with at `index` from a V8 `Object` handle.
Signature:
```c++
void* Nan::GetInternalFieldPointer(v8::Local object, int index)
```
Calls the Object's [`GetAlignedPointerFromInternalField()` or `GetPointerFromInternalField()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#ab3c57184263cf29963ef0017bec82281) depending on the version of V8.
### Nan::SetInternalFieldPointer()
Sets the value of the internal field at `index` on a V8 `Object` handle.
Signature:
```c++
void Nan::SetInternalFieldPointer(v8::Local object, int index, void* value)
```
Calls the Object's [`SetAlignedPointerInInternalField()` or `SetPointerInInternalField()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#ad7f5dc559866343fe6cd8db1f134d48b) depending on the version of V8.
### Nan::AdjustExternalMemory()
Signature:
```c++
int Nan::AdjustExternalMemory(int bytesChange)
```
Calls V8's [`AdjustAmountOfExternalAllocatedMemory()` or `AdjustAmountOfExternalAllocatedMemory()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#ae1a59cac60409d3922582c4af675473e) depending on the version of V8.