Related to my previous question:
Preventing Memory issues when handling large amounts of text
Is there a way to determine how much memory space my program is occupying? I end up processing a large amount of text file and usually store the processed objects in memory. There are times where there will be too much information, and I will run out of memory. I have a solution for avoiding the memory allocation problem, but I only want to use it when necessary, to avoid paging, which will ultimately decrease my performance when it's not necessary. Is there a way to figure out how much memory I am occupying, so that I can page my information only when necessary?
NOTE: I am looking for a solution that my program can utilize to begin paging when necessary.
Check Computer Memory Usage EasilyTo open up Resource Monitor, press Windows Key + R and type resmon into the search box. Resource Monitor will tell you exactly how much RAM is being used, what is using it, and allow you to sort the list of apps using it by several different categories.
4GB of RAM is the bare minimum memory needed to run a base computer model.
You can use it by putting the @profile decorator around any function or method and running python -m memory_profiler myscript. You'll see line-by-line memory usage once your script exits.
Tap Developer options and then tap Memory. In the resulting screen (Figure B), you'll see a list of the average memory used by the device in the past three hours (you can adjust the time frame, by tapping the time drop-down at the top). The Memory usage window in Android 12.
long bytes = System.Diagnostics.Process.GetCurrentProcess().WorkingSet64;
You can try GC.GetTotalMemory
:
Retrieves the number of bytes currently thought to be allocated. A parameter indicates whether this method can wait a short interval before returning, to allow the system to collect garbage and finalize objects.
The important thing to note is this part: "Retrieves the number of bytes currently thought to be allocated". This means that this method may not be 100% accurate - as long as you know this going in, you should be able to get a rough idea of your virtual memory utilization at a given point in your application execution.
Edit: Let me now offer a different solution that will probably be more productive: use perfmon
and the CLR performance counters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With