Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

371
Visualizações
Memory usage of program increasing over time, but memory leak tools report no issues

I am working on a fairly large library that continuously allocates and frees memory as it executes. For the past few weeks I have been trying to keep the memory consumption stable, but it appears to be increasing over time. The behavior I can't quite explain is that the increase is not linear. There is a "baseline" memory level that the process hovers at for a while, and then it jumps to a new "baseline". As time passes, the jump entails more and more memory. So let's say memory usage jumped from 512kb to 1024kb after a few hours of operation. It might go from 1024 to 2048 overnight hours. Then it might jump to 4096kb next time. Here is a chart of what memory usage looks like:

chart of memory usage

I have it running on Linux and Valgrind gives it a clean bill of health, if this is relevant at all. I am using the Linux code here to display the virtual memory consumption of my process:

int getValue(){ //Note: this value is in KB!
FILE* file = fopen("/proc/self/status", "r");
int result = -1;
char line[128];

while (fgets(line, 128, file) != NULL){
    if (strncmp(line, "VmSize:", 7) == 0){
        result = parseLine(line);
        break;
    }
}
fclose(file);
return result;
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You are most likely suffering from memory fragmentation.

What happens is that as you release chunks of memory, you get little holes which might not be able to be used next time you request memory. As you continue allocating and releasing in a pattern that creates small unusable holes, the only solution is to get more hunks of memory from the system.

If you have well-defined rules for how your program uses memory for specific things, you might want to consider a memory pool to help allocate and release memory according to the specific requirements of your program, rather than the general-purpose requirements of the standard library.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda