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
-
217
votes4
answers41133
viewsWhat are they and where are the "stack" and "heap"?
What are these such stack and heap that so much is said about memory management? This is actually portions of memory as some people speak or is just an abstract concept to facilitate understanding…
-
51
votes2
answers4996
viewsMemory allocation in C# - Value types and reference types
In C# there is a difference between the form that memory is allocated by the CLR for reference types (classes) and value types (structures). The difference, from what I’ve always heard, would be…
-
39
votes2
answers1301
viewsHow does the G1 (Garbage First Collector) work?
In the JEP-248 the definition of G1 has been discussed (Garbage First Collector) as the standard Garbage Collector on Java 9. In this period, I have heard many quotes about the G1, but very little…
java performance memory-management jvm garbage-collectorasked 9 years, 4 months ago Reginaldo Soares 2,256 -
37
votes3
answers439
viewsHow to get a similar behavior between the Garbage Collection of a Single-Page Application and a Multiple-Page Application?
I’ve been doing a lot of research on the web and in stackoverflow communities, and I’m getting to the point of believing that Spas take almost no advantage of the GC algorithm of current browsers.…
javascript memory memory-management single-page-application memory-leaksasked 7 years, 6 months ago LeonanCarvalho 3,527 -
29
votes1
answer7393
viewsWhy does Java consume so much memory?
I wrote this little program in Java to download images of a thread in a imageboard: public class FourChanThreadImageDownloader { private static void usage() { System.out.println("java…
-
28
votes3
answers1436
viewsHow does method management work in C#memory?
In C# there is a clear distinction between value types (structs) and reference types (classes), this distinction being basically the way in which the CLR manages instances of each type. Value type…
-
28
votes1
answer1626
viewsWhat is Flyweight Pattern?
Researching a little to better understand the logic that leads strings in Java to be immutable, I found out that "internment" of Strings is an example of the pattern Flyweight. In accordance with…
pattern-design software-engineering memory-management immutability flyweightasked 8 years ago Anthony Accioly 20,516 -
24
votes3
answers1024
viewsShould I free up all the allocated memory when finishing a program?
It is commonly accepted that when I allocate a block of memory I am responsible for releasing it. This is particularly true when programming based on RAII. However the following program works…
-
23
votes2
answers1963
viewsWhat is the purpose of the free() function?
In which cases should it be used? There is an alternative? It is recommended to use?
-
21
votes2
answers3969
viewsWhat is Garbage Collector and how does it work?
What is Garbage Collector, how it works? When should we care about him?
-
18
votes3
answers1132
viewsWhen to use finalizers and garbage collection in Java?
When to use the methods System.gc() and finalize()? I read that it is very useful in object orientation to destroy memory objects that are not being referenced and to finish tasks, but I see few…
-
17
votes2
answers6315
viewsHeap of Java memory
I would like a simple explanation of what heap memory of JVM? I searched on Google but had no clear enough answer.
-
17
votes1
answer484
viewsData access performance in heap and stack and object allocation
Data access in the stack is faster than in heap? And why allocate an object to heap?
-
17
votes3
answers959
viewsWhy does calling System.gc not guarantee running the Garbage Collector?
Why the developer does not have full control over the Garbage Collector? I understand that the role of GC is to automatically manage the memory but why even using some method like the System.gc…
-
15
votes2
answers1826
viewsHow is a program loaded into memory and then executed?
Imagine that I wrote a "hello world" in C. I compiled and generated an executable, then ran it. The result of the build is a binary, which is actually also a set of instructions that will be…
-
14
votes2
answers2001
viewsDoes Delphi own a garbage collector?
Does Delphi have an automatic garbage collector? How does it work. If not, what tools can do this?
delphi memory memory-management garbage-collector object-pascalasked 9 years, 8 months ago Giovani 2,875 -
12
votes1
answer218
viewsHow does "free()" know how much memory it has to release?
When we use the malloc() we say how many bytes we need. But free() we do not say. How he knows how much he needs to be released?
-
11
votes1
answer255
viewsCanonicalized Mapping and Weakreference
I would like someone to explain the concept (and applications) of Canonicalizing Mapping and how your reference implementation would work using Weakhashmap.…
java performance memory-management hashmap garbage-collectorasked 9 years, 5 months ago Reginaldo Soares 2,256 -
11
votes2
answers811
viewsWhat is memory segmentation?
I read about memory segmentation, however, I cannot understand what memory segmentation is and how it influences the functioning of my program. Illustration See this example of a program that…
-
10
votes3
answers9879
viewsHow to free all memory allocated by an object - Delphi
What is the best way to free all memory allocated by creating an object for S.O. Let’s not consider: Objeto.Free; Objeto := Nil; Sysutils.FreeAndNil(Objeto); There would be more ways to free the…
-
10
votes2
answers158
viewsWhat happens to memory when "realloc()" reallocates a memory block to a value less than the original?
Suppose I allot a dynamic matrix of 10 ints and assign some values values to it, then I use the function realloc() to reallocate the matrix to 3 ints, what happens to the other 7 ints, they will be…
-
9
votes1
answer325
viewsIn C++ where are the functions of the objects in memory?
In C++ when an object is declared, class variables are stored in the stack or in the heap depending on how the object was created. With the operator sizeof() it is possible to test and realize that…
-
9
votes2
answers477
viewsWhat types of resources are released in a "using" statement?
According to Microsoft documentation: The using statement provides a convenient syntax that ensures use correct of Idisposable objects. Source. That is, the interface Idisposable provides a…
-
8
votes2
answers213
viewsDo I need to assign null to a variable after use?
There is a need to allocate null in the object after its use? In the example below just after using the list I have a method that takes a lot of time to run. I need to assign null to the list to…
-
8
votes1
answer305
viewsImpact of the Garbage Collector
The project here of the company is done in Windows Forms and we do not manage memory very well, because it is a legacy system that has several years running. Currently we are facing problems with…
-
7
votes2
answers1416
viewsWhat is the behavior of static variables in . NET?
What is the behavior of static variables in . NET? These are stored in heap or in the stack?
-
7
votes1
answer82
viewsIs it possible to know at what point the script reaches the memory peak?
It is possible to know at what point the script reaches the memory peak? I have a PHP script that at the end shows this result: Usage: 380.515625Kb Peak: 393.5859375Kb Real: 512kb Example: <?php…
-
7
votes1
answer767
viewsChange of char variable content
I’m having trouble working with files and handling char. CODE char *fileTipoDespesaDefault; char *fileTipoPagamentoDefault; FILE *fileTipoDespesa; FILE *fileTipoPagamento; /** * tipos : 1 =>…
-
7
votes2
answers1375
viewsWhat’s the difference between On heap and Off Heap in Java - JVM Memory
I would like an explanation determining the characteristics of On heap and Off heap Memory in Java. We know that Thread Stacks, the code of our application and the Buffers NIO are all allocated Off…
-
7
votes2
answers111
viewsAccess to specific memory points
How do I access an exact address in memory on Windows? unsigned char * mem = {??};
-
7
votes2
answers7494
viewsHandling of malloc() and realloc()
I still don’t feel completely confident about using the malloc() or realloc(), these two ways are equivalent? 1) int main() { int x=0; char *s2,*s1; s1=NULL; s2=malloc(200); while(x++<3) {…
-
7
votes1
answer113
viewsIs there a difference between using discard or ignoring the value returned by a method?
I have a method similar to the below: public bool FazerAlgoERetornarSeSucesso() => true; And at some point, I need to call this method, but I don’t care about the result. Normally I would do…
-
6
votes4
answers1095
viewsWhy can’t I release memory?
I have the following code: #include "iostream" int main(){ int* A = new int[4]; int* B = A; delete[] A; delete B; if(B == NULL) std::cout << "B = NULL" << std::endl; else std::cout…
-
6
votes1
answer2424
viewsFree up memory in C++
I am obliged to release memory of every variable that I will no longer be using? If yes, how to do?
-
6
votes1
answer1184
viewsGarbage Collector for C++
I clearly understand what a Garbage Collector is and what it is for. It is very well known in Java. Is there a C++ library that implements GC or fixes memory lLeaks? I’ve searched the internet but…
-
6
votes2
answers413
viewsMemory management and release
1) When I create an object in which there is arrays and large variables, defining them as null, will help in the reduction? Within a method Dispose() - before they were of some value. 2) When I call…
-
6
votes1
answer298
viewsPerformance differences between structs and classes
I know the difference between structs and classes is that structs has its public members by default, and that structs belong to C (but nothing prevents use in C++). In practice when creating an…
-
6
votes1
answer132
viewsAre variables randomly allocated in memory?
In a book about C, in which I started studying variables, it said that variables were randomly put into memory, for example: int a; int b; printf("a = %d\n", &a); --> 5000 (endereço) (%d ao…
-
6
votes2
answers198
viewsstrcpy is merging numeric format with other chars
I don’t know if I made myself clear in the title, but when using strcpy() to copy a char* to another when I put a format like this "teste" it works normally, but when I put a string 3 letter format…
-
5
votes1
answer3064
viewsDifference between null and clear on an Arraylist
What’s the difference between: arrayList.clear(); and arrayList = null; The two do not destroy all elements of Arraylist?
-
5
votes1
answer332
viewsProblems with dynamic allocation
In an exercise I need to make a record of a struct possibly declared as follows:. typedef struct Locatarios { char nomeLocatario[MAX_NOME]; int codigoLoc; float valorAluguel; } Locatarios; It is…
-
5
votes2
answers912
viewsHow to free memory from an internal malloc to a function that returns a pointer?
How to release a malloc internal to a function that returns a pointer? In a simple way to try to exemplify my doubt, consider the following function f: int *f(int tam) { int *ptr = malloc(tam *…
-
5
votes1
answer1683
viewsHow to identify and avoid memory Leak in . NET?
I know CLR has tools like Garbage Collection, responsible for memory management in .NET. One of the functions of the garbage collector, GC, is to avoid unnecessary memory consumption. Even with the…
-
5
votes1
answer4783
viewsHow do I make an infinite loop without bursting the memory?
I’m trying to make a program that requests on a DDE server, so I need to collect the data every 0.1 sec. But with each iteration of the program the computer memory increases and at the end for the…
-
5
votes1
answer219
viewsIs it incorrect (or problematic) to create a string array struct?
I’m not sure what’s the ideal way to create a structure (struct) that contains a array of string, in case I have a structure like this: #include <stdio.h> #include <stdlib.h> typedef…
-
4
votes2
answers14165
viewsDynamic allocation for struct
I need to dynamically allocate space for a structure, but I am not able and I do not know my error is at the time of the statement or allocation, follow the functions consistent with the statement.…
-
4
votes1
answer1523
viewsCorrect use of free() in function?
How to use function free() when it is used within a function, in that function Gero a dynamic vector and the function itself will be the return, example: int* copia(int *vet, int tam) { int i,…
-
4
votes1
answer96
viewsWhy not give Segmentation fault when writing to a "char *" without allocating memory?
My question is whether the compiler automatically allocates memory to the variable s1 char *s1; char s2[20]; //s1=(char*)malloc (sizeof(char)*20); s1="palavra1"; strcpy (s2,"palavra2");…
-
4
votes0
answers31
viewsWhat is a TLAB and what is it for?
I recently used Java Mission Control (JMC) to track a memory Leak. In doing so I realized that JMC reports memory allocations inside and outside of Thread Local Allocation Buffers (TLAB). In a quick…
-
4
votes2
answers145
viewsLeaking memory in PHP
Leaking memory or Leaky memory occurs when a computer program does bad memory allocation management such that memory that is no longer needed is not released. I’d like to understand how the Leaking…