[nodejs] What's different of requiring json or js?

2012-08-05 Thread Kei Son
I have a huge JSON file, right, it's 78MB. When I just require it from node-cli it takes 450MB memory footprint. I can understand that is bloated 6x times because the JSON file is just a string in the storage, but it needs spaces for indexing, making some padding, optimization, linking and what

Re: [nodejs] What's different of requiring json or js?

2012-08-05 Thread Joshua Gross
There may be a better answer for this, but JSON is actually more rigidly structured than standard JavaScript. So, it makes sense to me that a more specialized parser would need more memory than just sending JavaScript code to the VM. -- Joshua Gross Christian / SpanDeX, Inc. / BA Candidate of

Re: [nodejs] What's different of requiring json or js?

2012-08-05 Thread Kei Son
makes sense. different parser needs more extra spaces. however the spaces for the parser-only should be freed at gc time, isn't it? 2012년 8월 6일 월요일 오전 5시 31분 3초 UTC+9, Joshua Gross 님의 말: > > There may be a better answer for this, but JSON is actually more rigidly > structured than standard JavaS

Re: [nodejs] What's different of requiring json or js?

2012-08-05 Thread Marak Squires
You might want to consider using a streaming JSON parser. On Sat, Aug 4, 2012 at 7:43 AM, Kei Son wrote: > I have a huge JSON file, right, it's 78MB. > When I just require it from node-cli it takes 450MB memory footprint. I > can understand that is bloated 6x times because the JSON file is just

Re: [nodejs] What's different of requiring json or js?

2012-08-05 Thread Kei Son
Thanks for the idea. But I just want to know why. 2012년 8월 6일 월요일 오전 9시 58분 22초 UTC+9, Marak Squires 님의 말: > > You might want to consider using a streaming JSON parser. > > On Sat, Aug 4, 2012 at 7:43 AM, Kei Son wrote: > >> I have a huge JSON file, right, it's 78MB. >> When I just require it fro

Re: [nodejs] What's different of requiring json or js?

2012-08-06 Thread Tim Caswell
On Sun, Aug 5, 2012 at 3:31 PM, Joshua Gross wrote: > There may be a better answer for this, but JSON is actually more rigidly > structured than standard JavaScript. So, it makes sense to me that a more > specialized parser would need more memory than just sending JavaScript code > to the VM. Tha

Re: [nodejs] What's different of requiring json or js?

2012-08-06 Thread Kei Son
https://github.com/joyent/node/blob/ed7fb149a20ee5e7aa9a0574a242a193d7acd761/lib/module.js#L464 As we can see at #465 and #472, I'm pretty sure that there is no dumb and buffering things on Node.js side. Unless there are some magic in the module._compile() as the opposite. And i totally agree o