gerenciamento-de-memória

Memory allocation in C# - Value Types and reference types

In C# there is a difference between how memory is allocated by the CLR for reference types (classes) and value types (structu ... does this distinction exist? After all, classes and structures, despite having differences, are quite similar to each other.

How to identify and prevent memory leak no.NET?

I know that CLR has tools like garbage collection, responsible for memory management in .NET applications .one of the functi ... ory to be able to allocate. How to identify these leaks in the .NET application and what practices to adopt to prevent them?

How to allocate a dynamic stack, with size provided by the user?

I want to allocate a dynamic stack with the size provided by the user, then treating it as a "vector" would be more or less w ... == NULL) return 0; Elem* no; no = (Elem*) malloc(tam * sizeof(Elem)); if(no == NULL) return 0; }

Dynamic allocation with struct

/* [Error] expected primary-expression before'*' token [Error] 'dia' was not declared in this scope [Error] 'mes' wa ... 10; ptr->ano=1990; printf("%i",dia); printf("%i", mes); printf("%i",ano); system("pause>null"); return 0; }

What is Flyweight pattern?

Researching a bit to better understand the logic that leads strings in Java to be immutable , I found that "Internation" of ... e Flyweight pattern ? When should we use it and what would be good examples of using this technique besides string interning?

Malloc does not work in C code

When trying to compile the code I get the following error messages: #include <stdio.h> #include <stdlib.h> # ... ; default: printf("Operação não disponível\n"); break; } } while(opcao != 0); return OK; }

What is the behavior of static variables no.NET?

What is the behavior of static variables in .NET? are they stored in the heap or in the stack?

Break text and store in vector

I want the program to be able to store only 1 Sentence per line. Being that each sentence is possible to be terminated accord ... } } matriz = realloc(matriz, sizeof(char *) * linha); for (i = 0; i < linha; i++) { printf("%s\n", matriz[i]); } }

first-fit, best-fit and worst-fit python

I have to make a software that implements the memory management algorithmsfirst-fit, best-fit and worst-fit, I know their co ... this doubt for me I would be very grateful and sorry if this doubt is half noob for I am learning a short time programming.

How does memory management work, with virtual memory?

Good I am doing the discipline of operating systems and a doubt arose while reading memory management. From what I've read, ... process will be saved in the pages and the MMU does the calculation pro absolute address not need more base and limit logger.

Dynamic allocation for struct

I need to dynamically allocate space for a structure, but I am not able and do not know of my error is at the time of declara ... "\t Estado: "); ler_string(info[posicao].estado, 2); printf("\t CEP: "); scanf("%lu", &info[posicao].cep); }

When to allocate memory dynamically?

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 ... r type, ie start, we do not know how much memory the program will use and even then, it was not necessary to use new + delete

What are they and Where are the "stack" and "heap"?

What are these stack and heap that talk so much about memory management? Are these really portions of memory as some people ... derstood by programmers. An explanation would be very useful for those who are starting out or have learned it the wrong way.

Dynamic vector allocation

Follows the statement: Make a program that reads keyboard numbers and stores them in a dynamically allocated vector. T ... = 0); printf("\n\n") ; for (int i=0; i<c2; i++) printf("%d ", vet[i]); system("pause"); return 0; }

Handling malloc() and realloc()

I still don't feel completely confident about using malloc() or realloc(), are these two ways equivalent? 1) int main() { ... mory? scanf(" %s", s2); s2=malloc(strlen(s2)); What does it really do a malloc() and realloc() internally in memory?

Is it always good to deallocate memory before a "abrupt" exit of the program with the call of the exit function?

When I was starting to learn pointers and dynamic memory allocation in C, I was told that all memory allocated in the program ... ion, where in the event of an error would a call to exit() be required? Is it recommended to do a deallocation before exit()?