3

How can I read the size from an javascript object?

My idea: convert object to json string count all letters

result * 8 = size in KB

But i think this is very dirty, an ideas? Thanks in advance!

Makram Saleh
  • 8,613
  • 4
  • 27
  • 44
Peter
  • 11,413
  • 31
  • 100
  • 152
  • Take a look at http://stackoverflow.com/questions/1248302/javascript-object-size – Murali VP Jul 19 '11 at 08:00
  • What part of the size do you need? The number of elements? The total bytes of memory? – Ariel Jul 19 '11 at 08:01
  • "size" is a slightly vague term, but if you mean the amount of space an object is taking up in memory, then simply multiplying the length of a JSON representation has some issues, first and foremost is that not all character sets are one byte per character. Additionally you also have to take the markup of the JSON string itself into account, you don't want to include the characters that describe the encoding of the object into account (unless they happen to occur in a string inside the object in questions). – GordonM Jul 19 '11 at 08:32

1 Answers1

0

I found this in the documentation

Size of a single write request to the database 256 MB from the REST API; 16 MB from the SDKs. The total data in each write operation should be less than 256 MB. Multi-path updates are subject to the same size limitation.

Hope it helps :)

https://firebase.google.com/docs/database/usage/limits