Skip to content

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

Closed

Description

@bootstraponline
  • 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]],
   // ...
]);

Activity

  1. added
    typescript
    on Nov 23, 2017
  2. KuromiAK commented on Nov 26, 2017

    @KuromiAK
    Contributor

    Change the code in this way seems to help?

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

    @bootstraponline
    Author

    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]);
      
    ...
  4. mjbvz commented on Nov 27, 2017

    @mjbvz
    Contributor

    This issue was moved to microsoft/TypeScript#20279

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

Metadata

Metadata

Labels

typescript

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions