memory leak?
Los mantenedores suelen responder en 12 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
Línea de trabajo
Comienza con la demo create_monitor_with_helpers proporcionada y reproduce el bucle mientras observas malloc_stats(). Rastrea la propiedad y la limpieza del objeto cJSON, la cadena generada y las asignaciones repetidas; después, compara los bytes en uso a lo largo de iteraciones repetidas. Se considera terminado cuando se haya establecido la causa y cualquier corrección se haya verificado con un resultado de memoria reproducible.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
I write a demo test using cjson:
creating json object with array, the array size is rand, code is as follow.
i run the code, check heap size real-time, but i found,
in use bytes is increasing never decrease,
is memory leak? or i am wrong? any help, thanks!
`
/*
- cJSON test examples
*/
#include <stdio.h>
#include <stdlib.h>
#include "cJSON.h"
#include <malloc.h>
#include <string.h>
#include <unistd.h>
//NOTE: Returns a heap allocated string, you are required to free it after use.
char *create_monitor_with_helpers(void)
{
const unsigned int resolution_numbers[3][2] = {
{1280, 720},
{1920, 1080},
{3840, 2160}
};
char *string = NULL;
cJSON *resolutions = NULL;
size_t index = 0;
cJSON *monitor = cJSON_CreateObject();
if (cJSON_AddStringToObject(monitor, "name", "Awesome 4K") == NULL)
{
goto end;
}
resolutions = cJSON_AddArrayToObject(monitor, "resolutions");
if (resolutions == NULL)
{
goto end;
}
int N = 1000;
int value = rand() % (N + 1);
printf("rand value %d\n", value);
//for (index = 0; index < (sizeof(resolution_numbers) / (2 * sizeof(int))); ++index)
for (index = 0; index < value ; ++index)
{
cJSON *resolution = cJSON_CreateObject();
if (cJSON_AddNumberToObject(resolution, "width", value) == NULL)
{
goto end;
}
if (cJSON_AddNumberToObject(resolution, "height", value) == NULL)
{
goto end;
}
cJSON_AddItemToArray(resolutions, resolution);
}
string = cJSON_Print(monitor);
if (string == NULL)
{
fprintf(stderr, "Failed to print monitor.\n");
}
end:
cJSON_Delete(monitor);
return string;
}
/*
-
Main
/
int main() {
char out;while(1){
malloc_stats();out = create_monitor_with_helpers(); printf("packing %ld char string\n", strlen(out)); //printf("%s",out); free(out); sleep(1);}
return 0;
}
`
runing about 5 minute, malloc_stats() output increasing to as follow:
Arena 0:
system bytes = 704512
in use bytes = 92304
Total (incl. mmap):
system bytes = 704512
in use bytes = 92304
max mmap regions = 0
max mmap bytes = 0
about 90K byte.
- Lenguaje dominante
- C
- Estrellas
- 13k
- Forks
- 3.5k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de DaveGamble/cJSON
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
DaveGamble/cJSON#1106 ·
Los mantenedores suelen responder en 12 días
-
Undefined-Behavior in function cJSON_SetNumberHelperPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
DaveGamble/cJSON#1100 · 1 reacción ·
Los mantenedores suelen responder en 12 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
DaveGamble/cJSON#1094 · 9 comentarios · 1 reacción ·
Los mantenedores suelen responder en 12 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
DaveGamble/cJSON#1093 ·
Los mantenedores suelen responder en 12 días
-
Use-after-free in cJSONUtils_ApplyPatches when a patch removes the patch arrayPosiblemente ocupada @iliasabk la tomó hace 31 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
DaveGamble/cJSON#1082 ·
Los mantenedores suelen responder en 12 días
Todos los issues de DaveGamble/cJSON
Issues similares
-
[WinReg] update to v12.0.0Abiertocategory:port-update
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 2 días
-
feat(palindrome): add C solutionPosiblemente ocupada @aadiitya2007 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
techcsispit/code-corner#58 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[LOGO] Add Ruxt Linux LogoAbiertologo request
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
fastfetch-cli/fastfetch#2661 ·
Los mantenedores suelen responder en 1 día
-
Mark ignored Mac OS partitions RecoveryOSContainer and iBootSystemContainerPosiblemente ocupada @meven la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
storaged-project/udisks#1559 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 71/100
awslabs/aws-checksums#121 ·