Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

372
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda