Page 134 - Nodejs 교과서 개정2판
P. 134

buffer-memory.js
           const	fs	=	require('fs');


           console.log('before:	',	process.memoryUsage().rss);


           const	data1	=	fs.readFileSync('./big.txt');
           fs.writeFileSync('./big2.txt',	data1);
           console.log('buffer:	',	process.memoryUsage().rss);




          콘솔

           $	node	buffer-memory
           before:	18137088
           buffer:	1019133952




         ୊਺ী   .#৓؍ ݫݽܻ ਊ۝੉ ࣽधрী  (#ܳ ֈ঻णפ׮   (# ਊ۝੄ ౵ੌਸ ࠂࢎೞӝ ਤ೧ ݫݽܻী ౵
         ੌਸ ݽف ৢ۰ك റ writeFileSyncܳ ࣻ೯೮ӝ ٸޙੑפ׮


         ੉ߣীח झ౟ܿਸ ࢎਊೞৈ ౵ੌਸ CJH  UYU۽ ࠂࢎ೧ࠁѷणפ׮

          stream-memory.js

           const	fs	=	require('fs');


           console.log('before:	',	process.memoryUsage().rss);


           const	readStream	=	fs.createReadStream('./big.txt');
           const	writeStream	=	fs.createWriteStream('./big3.txt');
           readStream.pipe(writeStream);
           readStream.on('end',	()	=>	{
           		console.log('stream:	',	process.memoryUsage().rss);
           });



          콘솔

           $	node	stream-memory
           before:	18087936
           stream:	62472192




         झ౟ܿਸ ࢎਊ೧ࢲ ౵ੌਸ ࠂࢎ೮؊פ ݫݽܻܳ   .#߆ী ର૑ೞ૑ ঋणפ׮  ੉੹ ߑध੉  (# ਊ۝ਸ ର૑
         ೮؍ Ѫী ࠺ೞݶ ষ୒դ ѐࢶ ബҗੑפ׮  ௾ ౵ੌਸ ઑпղয ੘਷ ߡಌ ױਤ۽ ৤҂ӝ ٸޙੑפ׮  ੉ۧѱ झ

         ౟ܿਸ ࢎਊೞݶ ബҗ੸ਵ۽ ؘ੉ఠܳ ੹࣠ೡ ࣻ ੓णפ׮  ز৔࢚ э਷ ௾ ౵ੌٜਸ ੹࣠ೡ ٸ ੉۞ೠ ੉ਬ۽
   129   130   131   132   133   134   135   136   137   138   139