4

I have array of objects containing around 200000 records. The objects have long key names. Will shorter property names consume less memory? Will it be enough to make a difference in performance?

If I prepare my data like:

[{"dTN":"datatype value","dTR":"dataType range"},....]

instead of:

[{"dataTypeName":"datatype value","dataTypeRange":"dataType range"},....]

how it will effect memory usage in browsers?

Can anyone please explain how javascript handles object property names?

JAAulde
  • 19,250
  • 5
  • 52
  • 63
Vikram Singh
  • 924
  • 1
  • 9
  • 23
  • 1
    I assume you're asking about the memory usage after you've parsed it and no longer need the original JSON data string? Or no? After it's parsed, it really isn't JSON anymore, so I can't tell which you're asking about. –  Apr 21 '17 at 13:35
  • 1
    It will help to load parts of the data on demand instead of a huge object – baao Apr 21 '17 at 13:35
  • 1
    @squint yes after parsing how it will use memory – Vikram Singh Apr 21 '17 at 13:36
  • I'm going to bet that property names are efficiently reused internally, so if you have many repeating objects of the same structure, they're going to be stored and referenced. We do know that at least Chrome creates reusable classes internally, but I don't know if that translates to data that came from JSON. –  Apr 21 '17 at 13:40

1 Answers1

0

You can check using window.performance.memory in Chrome.

If you have many repeating strings I believe they will be optimized, this completely depends on the engine of course. If the keys are all different you might see an increase.

Community
  • 1
  • 1
Halcyon
  • 57,230
  • 10
  • 89
  • 128