Most voted "memory-management" questions
Memory Management is the field in which questions related to the techniques of use, allocation and memory recycling used by a program are studied.
Learn more…125 questions
Sort by count of
-
4
votes1
answer126
viewsWhy am I getting access to this pointer even after I’m free?
I have this program and theoretically it was not to lose the address of new after giving the free making the same inaccessible ? #include <stdio.h> #include <stdlib.h> typedef struct{…
-
4
votes2
answers501
viewsWhen to dynamically allocate memory?
In C++ you can easily declare an object or variable like this: tipo_da_variável nome_da_variável; This type of statement is the easiest to use, but you can also use the new to dynamically allocate…
-
4
votes1
answer92
viewsHow can Stack expressions handle stack variables?
I’m learning C# and I’m reading about Brazilian expressions. The question is: how does it work and why does it work? public delegate void Test(); public void Foobar(ref Test del) { int var = 10; del…
-
4
votes2
answers522
viewsDynamic allocation of vectors
Follows the statement: Make a program that reads keyboard numbers and store them on one dynamically allocated array. The user will type in a sequence of numbers, no quantity limit. The numbers will…
-
3
votes1
answer1235
viewsDestruction of an instance
How do I destroy an instance? I have an object whose instance is referenced in various parts of my code. At some point I need to delete this object and for that I am doing the following: meuObjeto =…
-
3
votes1
answer1361
viewsProgram memory cleaning in use
My application is accumulating memory, only thing it does, that’s the bottom. After 10-15 minutes, it comes to consume more than 1.5GB of memory, and continues consumption non-stop. Run a Timer…
-
3
votes2
answers108
viewsMemory Leak in Xmlserializer
I have the code below. How the method is static and the XmlSerializer does not implement the Dispose, at each call of the method, the system stacks in memory or the GC (Garbage Collector) can clear…
-
3
votes1
answer634
viewsHow do I let the string size be set by scanf()?
My question is about the theory. I know it’s possible to make a string without limiting the size of the: char teste[] = "Teste"; however, I would like to know if it has how to do the same thing, ie…
-
3
votes2
answers337
viewsHow does the destructor ("__destruct" method) work in PHP?
A big difference from PHP to Java, which is my native language, is that in Java there is no way to destroy objects that are in disuse, because the JVM already does it for us automatically, with the…
-
3
votes2
answers425
viewsUse delete on allocated objects without new?
Hello, from always until today in my c++ projects with Qt, I have always used delete objects only when I dynamically allocate them with the operator new, But in my last project that was relatively…
-
3
votes1
answer715
viewsHow to increase performance in PHP?
If I increase the memory_limit (default: 256MB) in PHP settings, my application will run faster or I will end up losing performance because it consumes more server CPU processing?…
-
3
votes1
answer601
viewsReturn local function variables
I have two methods: // Apenas define um vetor de 4 posições e retorna ele int *verticesFromFace(int v1, int v2, int v3, int v4) { int vertices[4] = {v1, v2, v3, v4}; return &(vertices); } //…
-
3
votes1
answer98
viewsHow does malloc() organize memory?
When I allocate memory with malloc(), address equals an array? Or are spread across the PC memory? I want to create a list of structs, to do this, I have to have several structs in case, I can do…
-
3
votes1
answer75
viewsSonarlint x Java GC, cancel or not object at the end of the execution?
I am passing Sonarlint in a somewhat old application and fixing several "problems", but I came across a code snippet similar to: public void fazerAlgo(final String param) { MeuObjeto m = new…
-
3
votes1
answer75
viewsVector problem with dynamic allocation
The intention of this program that I am doing is to serve as if it were a banking system in which the amount of accounts to be created does not have a previously defined amount. In the main(), i…
-
3
votes1
answer202
viewsProblem with dynamic allocation - realloc()
I’m doing a program that works as a payroll system, but I’m having trouble with the dynamic allocation part. The program runs only once and stops. No int(main) i put: printf("Sizeof :…
-
2
votes2
answers354
viewsWhat architecture and operating system properties allow a buffer overflow attack?
Attacks of the kind buffer overflow (data overflow or overflow) occurs when, while writing in a memory space, a program crosses the boundaries of the buffer and writes to an adjacent memory area. I…
-
2
votes1
answer894
viewsHello World on Android consuming a lot of RAM
I’m doing an application and I noticed that it is consuming a lot of RAM, approximately 70MB. I have a button that inflates an extra layout with random data and that keep changing dynamically that…
-
2
votes3
answers910
viewsError in fgets function
The program gives Segmentation fault (core dump) when executing the fgets function. Any idea? #include <stdio.h> #include <stdlib.h> #include <string.h> main (int argc, char…
-
2
votes0
answers446
viewsHow does Memory Management work with virtual memory?
Well I’m doing the Operating Systems discipline and a doubt has arisen while I read memory management. From what I read, one way to abstract memory is to use base and limit registers, where each…
-
2
votes2
answers173
viewsHow to Consume Less Memory in C#Runtime?
What I’d like to know is what are the most efficient ways to consume less memory in Runtime. Use of variables "Static" ? Create object with instants or a static class? Use of the Dispose() to free…
-
2
votes3
answers161
viewsSize of a character array according to its addressing
Is the size of a character array given by its address or by the value of the variable? Example: char[1000] = "Exemplo Teste" The size of this variable is 1KB due to its addressing char[1000] or her…
-
2
votes2
answers1641
viewsPass pointer pointer as argument for a function
I want to create an array using pointer pointer, but I’m having difficulty passing the parameters. First I dynamically allocate the matrix using a function. And then I read. The program compiled,…
-
2
votes1
answer300
viewsBreak text and vector store
I want the program to be able to store only one sentence per line. Each sentence is possible to be completed according to the signals I show in my code example. It does this but when printing on the…
-
2
votes1
answer138
viewsHow to avoid large SELECT memory stocking in Rails?
In the routine I’m developing, I do a simple SELECT in the bank, only in a table: Model.select("id").where(:tipo => 2).find_each do |registro| puts registro.id end But this select returns around…
-
2
votes1
answer197
viewsWhat does Java memory management accomplish in an assignment of a previously allocated variable in memory?
I would like to better understand what Java memory management does in the following situation. Knowing that I am suffering from performance problems, I am trying to take the utmost care not to make…
-
2
votes3
answers106
viewsHow to create unmanaged variables?
When a variable is created, a value in memory is allocated to it, which can be accessed by any system on the outside from the address of that memory. Creating a file to store the contents of a…
.net security-guard memory-management garbage-collectorasked 6 years, 4 months ago CypherPotato 9,292 -
2
votes3
answers80
viewsDo I need to re-allocate a structure in case I clean up just a part of it?
I have a struct who owns nome and horário for appointments. typedef Struct{ char nome[20]; char data[20]; }Dados; I make the statement: Dados *dados_cliente[quantidade]; I make the allocation…
-
2
votes1
answer88
viewsIncrease multidimensional array size at runtime
Problem: I maintain a 2D multidimensional array that has a dynamic size, is always growing, as I am not allowed to use vector I need to develop a strategy to increase the size of this array at…
-
1
votes2
answers580
viewsStruct with pointer and allocation
I can’t use the fscanf in a structure, I have already allotted the structures. #include <stdlib.h> #include <stdio.h> #include <string.h> struct Cliente { int numero; char *nome;…
-
1
votes2
answers420
viewsHow to remove a variable from memory?
How to remove a variable, not necessarily from the code, but from the memory/record, in C? Hypothetical example: char meu_byte; //codigo deleta_da_memoria(meu_byte); That generates something like:…
-
1
votes1
answer657
viewsSize of struct allocation
When declaring a normal variable of type int for example, the compiler goes there and, depending on the architecture, separates 4 bytes. struct exemplo{ int x; int b; }; int main(){ struct exemplo…
c++ pointer struct memory-management allocationasked 9 years, 7 months ago Alexsander Borgesdamaceno 541 -
1
votes1
answer207
viewsIs it correct to clean an internal malloc to a function with it?
Well given the following code is easy to do memory management: Code Example (in C): #include <stdio.h> #include <stdlib.h> int *criarValor(void){ int *valor = malloc(sizeof *valor);…
-
1
votes0
answers39
viewsWhen is it necessary to use GC.Collect()?
I know that in . NET/CLR, the Garbage Collector acts alone, without it being necessary to call him manually. There are cases where the Garbage Collector does not "collect" automatically? When it is…
-
1
votes1
answer61
viewsWhen I am instating a class I need to perform a 'delete' after using the object even if the class has a destructor?
If I instate a class and Gero an object from it obligatorily I have to displace the memory of that object at the end of its use, right? But if the class that originated my object has a destructor it…
-
1
votes1
answer236
viewsTraverse an array using malloc
In the course of some questions here in the SO I saw this example and I was left with doubts. #include<stdio.h> #include<stdlib.h> #include<conio.h> void main() { clrscr(); int…
-
1
votes1
answer694
viewsIdentify memory leak in c++?
Hello, I have recently had problems with the application I am developing. The application seems to lose performance during a certain run time. I checked my code but use only a single object…
-
1
votes1
answer1084
viewsPlace string in a character array
I am learning character matrix and wanted to make a simple program in which I create a character matrix 200x100, put a string at position 0 and printed. This is part of a larger program that I’m…
-
1
votes1
answer272
viewsHow to start an array with the value the user type is possible?
If all allocated memory is defined at the time of compilation, then how is this possible: int num{0}; cin >> num; int array[num]; From what I understand, this could only be possible if using…
array c++ memory-management allocation variable-declarationasked 6 years, 5 months ago silash35 483 -
1
votes2
answers82
viewsWhy does this code give Segmentation fault?
Whenever the first line of the map is filled in, a Segmentation fault, I wonder why. void newmap(int x, int y , int players){ int linha,coluna; char **map = (char **) malloc(sizeof(char*) * y); *map…
-
1
votes1
answer171
viewsMemory and CPU consumption during a denial of service attack. How to understand statistics?
The following line was on the Ubuntu crontab: */2 * * * * echo -e "`date`\n\n`free` \n\n`vmstat`\n" >> /home/hacker/free_vmstat_output.txt Extract from the free_vmstat_output.txt file two…
-
1
votes1
answer505
viewsMemory allocation error for multiple files "terminate called after Throwing an instance of 'Std::bad_alloc' what(): Std::bad_alloc" [C++]
I’m using a sorting algorithm for a digital voice signal processing project. This algorithm was developed to receive all audio signals in a single vector to do the processing, but I’m having…
c++ allocation memory-management multiple-file-upload memory-limitasked 4 years, 4 months ago Marcus Vinicius De Paula 21 -
1
votes1
answer179
viewsMalloc does not work in C code
While trying to compile the code I get the following error messages: #include <stdio.h> #include <stdlib.h> #define OK 0 void preencherVetor(int* vetor[], int tamanho) { int indice; for…
-
1
votes1
answer69
viewsC# - Outofmemoryexception when searching for thousands of Active Directory groups
I’m searching thousands of groups with hundreds of users each of Active Directory, but it’s consuming a lot of memory. It starts with about 300 MB and when it reaches about 1800 MB, seen in the task…
-
1
votes2
answers76
viewsError while creating string array
I’m having trouble trying to initialize a vector of strings my code is like this: #include <stdio.h> #include <stdlib.h> #include <string.h> int main(){ char *str[3];…
-
1
votes2
answers672
viewsAllocation overflows memory in recursive function in C
I created a program that keeps allocating 4 in 4 bytes of memory successively through a recursive function: #include <stdio.h> #include <stdlib.h> #define BUF 2 void overflow(int…
-
1
votes0
answers28
viewsDo the Rebase from DLL or EXE, is it worth it?
During the development of a Assembly, I ended up "discovering" the following option: Project Properties > Build > Advanced > DLL Base Address and searching for information about it, I…
-
1
votes2
answers113
viewsError translating structure code from C++ to C#
I’m trying to read a string of a process, I found this structure on the Internet: struct name { wchar_t nome[32]; }; I did it that way: struct name { public char[] nome = new char[32]; } And is…
-
1
votes1
answer1100
viewsfirst-fit, best-fit and Worst-fit python
I have to make one software implementing the memory management algorithms first-fit, best-fit and worst-fit, I know their concept, the first-fit puts the dice in the first space that fits, best-fit…
-
1
votes1
answer329
viewsHow to allocate a dynamic stack with user-provided size?
I want to allocate a dynamic stack with the size provided by the user, then treat it as a "vector" would be more or less what I did in the function ALOCA? #include <stdio.h> #include…