c# - Unable to use up spare memory -


i have following console application, has sole purpose of using spare memory on running machine:

static list<string> _str = new list<string>(); static int fill = 10000; static int _remainingmemory = 50;  static void main(string[] args) {     fillstring();      console.readline(); }  static void fillstring() {     long count = 0;     while (true)     {         try         {             if (++count % 500 == 0 || fill == 1)             {                 showmemory();             }              _str.add(new string('_', fill));         }         catch (outofmemoryexception)         {             if (fill > 1)             {                                                          fill = 1;             }             else             {                 console.writeline("not consuming memory...");                 return;             }         }     } }  private static void showmemory() {     system.diagnostics.performancecounter ramcounter;      ramcounter = new system.diagnostics.performancecounter("memory", "available mbytes");     console.writeline("memory remaining: {0}", ramcounter.rawvalue); } 

what use 1gb of memory, leaves 10gb free. so, question is, why code not use every last byte of memory on machine , bring standstill?

i'm using vs2015 under windows 8.1.

you application doesn't use memory directly. uses virtual memory. os maps memory pages. don't think memory. think address space default abstraction available app.

if app 32 bit, limited 2 gb virtual memory default. if large address aware can access 3 or 4 gb on 32 bit windows/64 bit windows respectively.

if app 64 bit available address space 8 tb. limited os's ability pages though (at least while anyway).


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -