Memory allocation of a service

Asked

Viewed 188 times

1

I have a problem, I need to check the amount of memory that a specific service is allocating.

Is there anything in C# that does this? Some class or method?

For all that I have seen, bring the general information of consumption of the PC.

  • It’s possible, but depending on how it looks, you didn’t give any details. Surely there is something magical that you put in and it guesses the amount of memory used for something unspecified. If you don’t know what you want to find out, you’ll find nothing. Then tell us what you want to know. Maybe you don’t need it at all.

  • Let me break it down for you. My system has a service Cacheservice.exe, it will allocate memory as it goes being used I would like to create a JOB in c# to go checking the amount of memory it is consuming.

2 answers

1

To know information about a service just take the process associated with this service and evaluate its properties:

// Pega todos os serviços ativos com o nome NomedoServiço.exe e faz uma inspeção superficial em suas propriedades
foreach(var Processo  in  Process.GetProcessesByName("NomedoServiço.exe")){

    Console.WriteLine($"{Processo}-{Processo.Id}");
    Console.WriteLine("-------------------------------------");

    Console.WriteLine($"  Uso de memória física  : {Processo.WorkingSet64}");              
    Console.WriteLine($"  Tempo de uso da CPU    : {Processo.TotalProcessorTime}");
    Console.WriteLine($"  Memória paginada       : {Processo.PagedMemorySize64}");
}

0

@Felipe Rosa You are wondering how much memory your application uses, this is what I understood.
Well, I found some publications that might help you, but you have to research operating systems, that will help you, come on, so:

What I found and what is as I understood from your question is Monitoring memory consumption and running time
Read more: http://www.linhadecodigo.com.br/artigo/3077/monitorando-o-consumo-de-memoria-e-tempo-de-execucao.aspx
This second is in English is more comprehensive but I believe I am connected to what you need
http://www.codeproject.com/Articles/18727/Customized-Task-Manager-in-NET-using-C-and-Windows
I believe that with these two models you will achieve your goal.
att
LMV

Browser other questions tagged

You are not signed in. Login or sign up in order to post.