Skip to content

40% CPU and Gigs of memory used parsing a map #20279

Closed

Description

@mjbvz

From bootstraponline on November 23, 2017 1:25

  • VSCode Version: 1.18.1
  • OS Version: Windows 10 Version 1709 (OS Build 16299.19)

Steps to Reproduce:

  1. git clone https://github.com/bootstraponline/hex.git
  2. git checkout dbf422b1856d054b01bd28193ca52ed9c4033ceb
  3. Open hex/ts/ in Visual Studio Code
  4. Change anything in the TypeScript files
  5. Observe gigs of memory used.

image

image

Reproduces without extensions: Yes

I have a large map. That appears to make TypeScript crazy. I'm not sure if there's a way to disable processing on a per file basis. This issue does not happen when using JSON instead of a map.

export let codes = new Map([
   ['03310001', ['Potion', 'Battle Items [0]', true]],
   // ...
]);

Copied from original issue: microsoft/vscode#38993

Activity

  1. mjbvz commented on Nov 27, 2017

    @mjbvz
    Author

    From KuromiAK (@KuromiAK) on November 26, 2017 0:28

    Change the code in this way seems to help?

    export let codes = new Map<string, [string, string, boolean]>([
       ['03310001', ['Potion', 'Battle Items [0]', true]],
       // ...
    ]);
    
  2. mjbvz commented on Nov 27, 2017

    @mjbvz
    Author

    From bootstraponline on November 26, 2017 3:9

    This helped the most. I'm not sure what causes gigs of memory usage. Maybe giant arrays in the constructor is an edge case.

    // Use map to preserve iteration order. Object.keys is undefined
    export let codes: Map<string, [string, string, boolean]> = new Map();
    export function initCodes() {
      if (codes.size > 0) { return; }
    
      codes.set('03310001', ['Potion', 'Battle Items [0]', true]);
      codes.set('74500001', ['Power Ex', 'Battle Items [0]', true]);
      
    ...
  3. removed their assignment
    on Nov 27, 2017
  4. mjbvz commented on Nov 27, 2017

    @mjbvz
    Author

    I confirmed that the TS Server process has the high cpu usage. The server logs don't have any helpful info

  5. locked and limited conversation to collaborators on Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issueVS Code TrackedThere is a VS Code equivalent to this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions