Skip to content

'IdleNotificationDeadline' is deprecated: Use MemoryPressureNotification() #953

Open
airbnb/node-memwatch
#15

Description

@cbratschi

Getting the following warning with Node.js 20.x:

../node_modules/nan/nan.h:686:39: warning: 'IdleNotificationDeadline' is deprecated: Use MemoryPressureNotification() to influence the GC schedule. [-Wdeprecated-declarations]
    return v8::Isolate::GetCurrent()->IdleNotificationDeadline(
...

This method will be deprecated soon.

https://chromium.googlesource.com/v8/v8/+/refs/heads/main/include/v8-isolate.h#1295

Activity

  1. added a commit that references this issue on Aug 1, 2023
  2. vrza commented on Nov 2, 2023

    @vrza

    While nan's IdleNotification could be changed to use MemoryPressureNotification with newer versions of v8, e.g.

    #if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 11 ||                      \
      (V8_MAJOR_VERSION == 11 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
      inline bool IdleNotification(int idle_time_in_ms) {
        v8::Isolate::GetCurrent()->MemoryPressureNotification(v8::MemoryPressureLevel::kModerate);
        return true;
      }

    It seems to make more sense to deprecate nan's IdleNotification, and perhaps introduce a new shim for MemoryPressureNotification to the nan API.

  3. kkoopa commented on Nov 2, 2023

    @kkoopa
    Collaborator
  4. vrza commented on Nov 2, 2023

    @vrza

    From reading the v8 API docs, while both IdleNotificationDeadline and MemoryPressureNotification boil down to embedder asking v8 to run GC, the semantics are different.

    Concretely the idea behind IdleNotification was for the embedder to notify the engine when they are idle, in order to minimize the chance of GC cycles interrupting actual work. And they would pass an amount of time, a "deadline" for the engine to try and do as much work as possible, and engine would return true if no more GC can be done at that point in time.

    On the other hand, the idea behind MemoryPressureNotification is for the embedder to notify the engine that they are running out of memory. Not necessarily when the embedder is idle, this can be called from a separate thread while the isolate is running JS code. The signature is also different, there is no deadline parameter, and no value is returned.

    So, while similar, the end user of the API (developer) would likely not just simply replace calls to IdleNotificationDeadline with calls to MemoryPressureNotification without making other changes to their code.

  5. added a commit that references this issue on Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions