Most voted "memory" questions
This tag is to be used with memory problems in programming. DO NOT use the tag for memory installation problems or any non-programming related subject. If the problem is memory management have a tag just for this.
Learn more…332 questions
Sort by count of
-
5
votes1
answer709
viewsWhy is strcpy() insecure?
I’m reading about secure programming, and I read that function strcpy(), of the C language, is an example of insecure. I also read that there is a secure version of this function, which would be the…
-
5
votes3
answers1740
viewsHow do I know how much memory my application uses in PHP?
I wonder if there is any way to know how much my PHP application is consuming memory. For example: I want to know, at the end of the script execution, how much PHP spent on the execution process of…
-
5
votes2
answers393
viewsIf array is the same as pointer, why does one need to be copied to a variable and another need not?
In that reply Maniero said that if the member of the structure was a pointer it would not need to copy the string into it. But arrays are not pointers? Why is it different?…
-
5
votes1
answer637
viewsHow is a "struct" organized in memory?
How access to struct? Can I put members in the order I want? How does the compiler know which part of the memory to access? What would this look like? struct { char ch1; short s; char ch2; long long…
-
5
votes1
answer248
viewsWhat is managed code?
In a conversation with a co-worker about what language was used to develop Windows, he said that many parts should still be developed in C and C++, as it was necessary to run unmanaged code. Other…
-
5
votes2
answers350
viewsHow to get the total memory occupied by the application?
I know there’s a GC.GetTotalMemory, but it only shows the consumption of managed memory. It has how to discover the full use of the application?…
-
5
votes2
answers83
viewsWhat is the syncblock?
I received a reply about a syncblock. Why is it necessary? I understand what I researched is about competition control. But why does every object need it if not everyone will have competition?…
-
5
votes1
answer123
viewsWhy is it possible to store a string on a char pointer?
Why char stores a single character and the pointer points to its value in memory, so it shouldn’t have just one character? Example: char *str = "Ola"; Why str does not store only one character?…
-
5
votes1
answer210
viewsWhat is the difference between %p and %d in C language?
Which means the memory address that appears with %p and the %d exactly? What’s the difference? int main() { int teste = 10; int *ptr = &teste; printf("%p\n%d",ptr, ptr); return 0; }…
-
5
votes1
answer742
viewsHow does Python manage memory when assigning different types?
I wanted to understand how dynamic typing is done. In Python, for example, when we create a variable with content a number int and then that same variable gets a string, the fact of not giving…
-
5
votes1
answer62
viewsCopied objects stay at different addresses?
When I have for example: $abc = new ZZZ(); $mno = $abc; The object $mno is the same as $abc? That is, do they have "memory addresses" alike? How do I print this "memory address"?…
-
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
answer580
viewsHigh memory consumption Java Swing application
I am developing a Java application but when performing some tests and noticed that when running the application, my memory consumption increases. And as the use, it always allocates more and more…
-
4
votes1
answer1023
viewsWhy is the size of a struct not the sum of the sizes of its variables?
For example, the following code: #include <stdio.h> struct exemplo{ char letra; int numero; float flutuante; }; int main() { printf("Tamanho do char: %u\n", sizeof(char)); printf("Tamanho do…
-
4
votes2
answers69
viewsHow should these variables end correctly without having a chance of memory Leak?
What is the right way to use the free() in that case, where ls_options will contain several ls_buffer_send? char **ls_options = (char**) malloc (200*sizeof(char)); char *ls_buffer_send = (char*)…
-
4
votes2
answers117
viewsHow do I use free() and return the same content?
I wanted to use the free() in ls_retorna in the following function, how could you do it with the best way? char* MemCpyX(char *as_origem, int an_inicio, int an_quantidade) { char *ls_retorno =…
-
4
votes3
answers408
viewsUse free() without malloc()?
May cause some problem in using the free() on a pointer that was not allocated with malloc() beyond the necessity itself? void funcao (int par) { char *palavra; if(par%2 == 0) { palavra =…
-
4
votes2
answers161
viewsProtecting data in memory
I read several articles on cryptography etc... The cryptography reported by posts was a success in my program, however some data remains in memory being vulnerable to Assembly readers in real time.…
-
4
votes2
answers358
viewsKeep variable in memory until system reboot
There is a way to keep a variable in the memory of the machine until it restarts? My application made a change in the system and sent the message to the user to restart the machine, to prevent any…
-
4
votes1
answer161
viewsIs it possible to copy files without using a stream buffer?
In my application, I have a class that periodically performs a backup of a file, considerably small (less than 1MB), but I am doing some tests and after reading this answer, it seems to me that it…
-
4
votes1
answer5675
viewsWhat is "overlay" and what is its connection to memory?
My college professor was talking about the term overlay in relation to memory. I was confused about this term. I’d like to know what it is overlay and what connection it has with memory?…
-
4
votes1
answer275
viewsWhat’s faster: Stack or Heap allocation?
This question may sound elementary but it has given me a good debate with a co-worker. I whenever I can make allocations on Stack because for me the growth of Stack is constant in time. And already…
-
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…
-
4
votes2
answers267
viewsBehaviour of malloc(1) in C
If I use char *char_commandout = (char *) malloc(1);, the allocated byte will store the " 0" at position 0 of the vector or will allocate a space for the value I want to store (at position 0) and…
-
4
votes1
answer142
viewsWhat happens to RAM if a key is pressed on the computer for a long time?
What happens to RAM if a key is pressed on the computer for a long time? Example: computer has been turned on and a key is pressed these bytes are being read by the processor and written in memory,…
-
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
votes2
answers588
viewsHow do I correctly access elements of a dynamic matrix via pointer?
As many know (I believe) a multidimensional matrix is stored in memory in a linear way, that is, each line of the matrix goes in memory one after the other. To illustrate I elaborated the following…
-
4
votes2
answers221
viewsHow to transform my code with static memory struct to C dynamics?
The exercise asks me to read information in a file, being them, Cpf, name, email and age of several people store in a struct, order in ascending order by age, if equal ages by Cpf, and print in…
-
4
votes2
answers70
viewsPointer pointing to another pointer, how to use the free() correctly?
When I have a pointer pointing to another pointer like: int *ponteiro1 = malloc(sizeof(int)); int *ponteiro2; *ponteiro1 = 5; ponteiro2 = ponteiro1; free(ponteiro2); And I use the command…
-
4
votes1
answer87
viewsWhat happens to memory space after the use of a local variable?
At the end of the execution of a function its local variables are "destroyed", correct? The spaces in memory have any values, in C we can notice when ordering to print a variable that we did not…
-
4
votes1
answer291
viewsComposition of objects in Python
In this case, I’m trying to understand how the connection between two classes and their objects. Since, when creating an object, a space in memory would be reserved for it, this space includes the…
-
4
votes1
answer124
viewsHow abstract are pointers in C?
I have a vision, which from time to time seems wrong, that C pointers are simply and literally memory addresses. In this case it starts from a misconception that memory was a linear thing and…
-
3
votes4
answers650
viewsReturn multiple arrays using a buffer without overloading memory
I’m developing an application where, in a report, I need to print something around 50,000 lines. When having run SELECT error occurs: Fatal error: Allowed memory size of 134217728 bytes exhausted…
-
3
votes3
answers3004
viewsAccess data from already instantiated classes
I need to access data contained in class variables already instantiated from other classes User_Info info = new User_Info() I think I would need the memory address that is the right "info"? public…
-
3
votes2
answers344
viewsSegmentation Fault (core dumped ) Array reading
I have a problem related to reading a array that produces the error Segmentation Fault (core dumped ) This is only the beginning of code development, but already presents an error after reading the…
-
3
votes3
answers211
viewsProgram using malloc twice
Why this program that divides a number into decimal notation, transforms it into binary notation and prints the number on the screen in the correct sequence (from bit most significant for the least…
-
3
votes2
answers332
viewsWhat is the behavior of the reference variable and the primitive variable?
What is the behavior of a variable of reference type (null) and primitive type (0) in memory before they are initialized. Where they are in memory?
-
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
votes1
answer109
viewsMemory allocation and wiping in C - how much should I worry about?
I’m learning C from the book "Use Your Head! C" (damn me). Given a lesson, I need to create a struct calling for "island" with the following code: typedef struct island { const char *name; const…
-
3
votes1
answer701
viewsWhat are C++ pointers really used for?
Where pointers are actually used? I’ve searched so many places and the example is always theoretical. I would like to know a real situation, an example within a real project in which pointers are…
-
3
votes1
answer271
viewsIs there a problem assigning a value to a pointer?
I’m referencing myself by this site here How to declare pointers in C Usually when we want to start an integer type variable, for example, we do int inteiro = 4;but what if we did int *inteiro_ptr =…
-
3
votes1
answer778
viewsTypedef struct with C character array not working
I’m trying to create a kind of constructive data, but I’m having problems with the strings. typedef struct { char nome[30]; int idade; } p; p x,y; x.nome = “ana”; x.idade = 20; y.nome = “caio”;…
-
3
votes2
answers74
viewsWhere is the function that a decayed lambda to pointer points to stored? How is it released?
I learned recently that I can do this: auto a = +[]{return true;}; a = +[]{return false;}; And I understood that a lambda that captures nothing can decay to a pointer for function, as confirmed by…
-
3
votes4
answers961
viewshow to generate an xml in memory
With the code below, I Gero a file and write somewhere, however, instead of writing to the disk, I wanted to generate in memory, as it does? using (var context = new…
-
3
votes1
answer280
viewsHow do I show the path of the php script running under the linux ps command?
How do I find the script path (eg: /var/www/html/script.php ) of PID PHP by the command ps linux? I’m in big trouble, have some PHP script consuming a lot of memory and cpu, when I give the command…
-
3
votes1
answer66
viewsHow to find out in which generation of Garbage Telescope an object is allocated?
Considering my previous question on the generations of the CG, would like to understand if considering the "moment" through which an object is passing within its life cycle, brings some benefit or…
-
3
votes1
answer115
viewsWhy does Shortstring consume more memory than an ordinary String?
I made an example here to see how much memory consumes each variable and noticed that a variable of type ShortString consumes 256 while a variable of type String consumes only 4. Following example…
-
3
votes2
answers714
views -
3
votes1
answer403
viewsHow to get the same strcpy() result with strcpy_s()?
I downloaded a C++ code from the internet and when I open the solution, the following error: Error C4996 'strcpy': This Function or variable may be unsafe. Consider using strcpy_s Instead. To…
-
3
votes1
answer100
views