Skip to content
Advertisement

Tag: malloc

Error in malloc while trying to create a thread

Hi everyone i post only the core of the code which create probleam and which work with threads. As we can see foo function create new thread and reallocate memory to store the pthread_t. Then it try to create a new thread with pthread_create as NULL as attr and arg and as function pointer a pointer to foo2; Now the

Understanding glibc malloc trimming

Some program that I am currently working on consumes much more memory than I think it should. So I am trying to understand how glibc malloc trimming works. I wrote the following test: Test output (without calling malloc_trim): Even though almost all memory was released, this test code consumes much more resident memory than expected: Process smaps: When I enable

Reuse char * pointer needs to free and malloc again?

I would like to implement a main function such as in order to execute system commands. The following code is currently used : Because I need to enter other commands, I am currently using the same cmd_buffer by using free() before reallocating memory. Is it the right way to do ? Some other commands might be required in the future.

Is malloc deterministic?

Is malloc deterministic? Say If I have a forked process, that is, a replica of another process, and at some point both of them call the malloc function. Would the address allocated be the same in both processes? Assuming that other parts of execution are also deterministic. Note: Here, I’m only talking about virtual memory, not physical one. Answer There

Advertisement