Message from C, C++ discussions

December 2019

— I looked some lectures, and one said that changing small vector to array in hot spot made program run 40-70% faster, but this are rare cases

Message permanent page


Not actually

In the case of allocating memory on stack we just need to reduce current stack pointer register, with heap we need to use system calls

I wouldn't call it benefit

Is there any other benefit?

— Any benefits could be measured, i will not assume any, having not so much experience

— And I'm talking only about these two cases, not vector:
int *heap = malloc(N bytes);
int stack[N elements];

Message permanent page

— Allocating memory on a heap costs more than on a stack

— Not always

— Talk about custom allocators

— Almost always

— That isn't the benefit, that I wanted to know :D

I already noticed the stack pointer

— You can allocate a big heap and use chucks of it later

— Hi

— I creat a txt file and get information from this file with ifstream . I write in the txt file name of people and their length. I want compare their lenght or choose the bigger one . How can i do ?

Message permanent page