Memory usage in C#

If you want the memory of the entire running process and not on a per thread basis, how about: // get the current process Process currentProcess = System.Diagnostics.Process.GetCurrentProcess(); // get the physical mem usage long totalBytesOfMemoryUsed = currentProcess.WorkingSet64; There’s a whole host of other process memory properties besides WorkingSet64 check out the “memory related” ones … Read more

How many chars can be in a char array?

See this response by Jack Klein (see original post): The original C standard (ANSI 1989/ISO 1990) required that a compiler successfully translate at least one program containing at least one example of a set of environmental limits. One of those limits was being able to create an object of at least 32,767 bytes. This minimum … Read more

C Memory Management

There are two places where variables can be put in memory. When you create a variable like this: int a; char c; char d[16]; The variables are created in the “stack“. Stack variables are automatically freed when they go out of scope (that is, when the code can’t reach them anymore). You might hear them … Read more