Skip to content

How to deal with strings longer than String::kMaxValue #712

Closed
@alexdima

Description

@alexdima
  • Node.js Version: 7.4.0
  • v8 Version: 5.6.326.50
  • OS: macOS Sierra
  • Scope (install, code, runtime, meta, other?): basic string manipulation
  • Module (and version) (if relevant): Buffer

Hi, I'm working on VS Code (based on Electron), and I'm looking into improving our memory usage when dealing with large files in microsoft/vscode#30180.

As part of testing opening large files in VS Code, we have some code paths where we end up creating a large string. e.g. select all + copy results in a large string being created that needs to be placed in the clipboard, etc.

v8's String::kMaxValue is defined as (1 << 28) - 16, which is 268,435,440 or about 256 MB and trying to create a string longer than that gives a "Invalid string length" exception straight from v8. I've seen nodejs/node#1374 touches on the topic and mentions improvements to ExternString.

Is ExternString exposed in any way to nodejs applications, or what is your guidance, when one needs to work with strings above 256MB?

Thank you.

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