Skip to main content
Stack Overflow
  1. About
  2. For Teams
Filter by
Sorted by
Tagged with
0 votes
2 answers
93 views

man 2 brk says: int brk(void *addr); brk() sets the end of the data segment to the value specified by addr ... On success, brk() returns zero. On error, -1 is returned, and errno is set to ENOMEM. ...
0 votes
0 answers
82 views

Note: sys_brk returns the program break while brk() returns 0 or -1.(According to manual brk(2), NOTES) The following code can pass. #include <unistd.h> #include <stdio.h> #include <...
1 vote
0 answers
66 views

Based on info in https://man7.org/linux/man-pages/man2/brk.2.html, the brk Linux system call works like this: void *sys_brk(void *desired_break) { return (void*)syscall(SYS_brk, desired_break); } It ...
pts's user avatar
  • 88.7k
1 vote
1 answer
691 views

I have a piece of code where I am using malloc_trim(0) to release any unused memory back to the system. But very intermittently I am see that it causes a crash. Backtraces below: Program terminated ...
1 vote
1 answer
201 views

Does this means using one of (malloc or calloc or realloc) and one of(brk/sbrk) concurrently results in UB or using both malloc and calloc can also cause UB? This happends through the entire program ...
0 votes
0 answers
444 views

I have a c++ service, where I am trying to debug the cause of high service startup time. From strace logs I notice a lot of brk() (which contributes to about 300ms, which is very high for our SLA). On ...
0 votes
2 answers
136 views

Code: int main() { printf("entering main. %p\n", sbrk(0)); void* ptr = malloc(300 * 1024); memset(ptr, 0xBE, 300 * 1024); printf("Allocated memory. %p\n", sbrk(0));...
0 votes
0 answers
111 views

I am currently working on a C program in Debian. This program at first allocates several gigabytes of memory. the problem is that after the startup of the program, still it is allocating memory. I ...
hpirlo's user avatar
  • 176
0 votes
0 answers
82 views

int main(int argc, char ** argv) { char *p[10]; for(int i =0 ; i < 10; ++i) { ssize_t msize = pow(2,i) * sizeof(char); p[i] = (char*)malloc(msize); printf(&...
CodeFish's user avatar
0 votes
1 answer
161 views

Heap allocators are responsible for actively requesting memory from the OS to grow the heap, e.g., with brk or mmap. Accessing unallocated memory leads to segfaults. I could design a different OS-user ...
0 votes
1 answer
172 views

I want to make sure the return address of sbrk is within a certain specific range. I read somewhere that sbrk allocates from an area allocated at program initialization. So I'm wondering if there's ...
AetX's user avatar
  • 213
2 votes
2 answers
2k views

I'm not sure if I'm asking a noob question here, but here I go. I also searched a lot for a similar question, but I got nothing. So, I know how mmap and brk work and that, regardless of the length you ...
1 vote
1 answer
524 views

for practice I'm currently trying to write my own malloc function in c. So my question is, after some allocation from the heap my program will freeze. I found the code segment which will couse the ...
0 votes
1 answer
1k views

I'm re-coding the malloc function using brk, sbrk & getpagesize() I must follow two rules: 1) I must align my memory on a power of 2 It means: If the call to malloc is : malloc(9); i must ...
1 vote
1 answer
117 views

From The Linux Programming Interface: int brk(void * end_data_segment ); The brk() system call sets the program break to the location specified by end_data_segment. Since virtual memory is ...
Rick's user avatar
  • 7,664

15 30 50 per page
1
2 3 4

AltStyle によって変換されたページ (->オリジナル) /