DotNet Memory Usage (VB.Net 2005/ .NET 2.0) -


please have @ following code:

'create array dim a(10000, 10000) integer 'print memory of application , physical memory console.writeline(process.getcurrentprocess.privatememorysize64) console.writeline(my.computer.info.availablephysicalmemory)  'do twice again dim b(10000, 10000) integer console.writeline(process.getcurrentprocess.privatememorysize64) console.writeline(my.computer.info.availablephysicalmemory)  dim c(10000, 10000) integer console.writeline(process.getcurrentprocess.privatememorysize64) console.writeline(my.computer.info.availablephysicalmemory)  integer = 0 10000     j integer = 0 10000         a(i, j) = 0     next next  console.writeline(my.computer.info.availablephysicalmemory) 

and output on system:

430125056 2466795520 839479296 2463166464 1273315328 2461618176 2065424384 

every initialized array occupies 400mb of memory in application, expected. available physical memory reduced 400mb after filling 1 of array values (the task manager shows 400mb used after loop...).

i thought initialized integer array occupies whole needed memory because filled 0. what's point?

availablephysicalmemory (http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.devices.computerinfo.availablephysicalmemory.aspx)

a ulong containing number of bytes of free physical memory computer.

i think key there 'physical' memory. understanding speaking actual hardware level of memory have available.

the privatememorysize64 memory 'assigned' current process. but, think of page swaps; memory process doesn't have physical @ all.

edit: think joe's comment better job of answering answer - doh!


Comments