Sponsored Content
Top Forums Programming Memory allocation for particular process in UNIX Post 302936801 by fpmurphy on Friday 27th of February 2015 10:32:32 PM
Old 02-27-2015
You can also use brk() if you are careful hhow you use it. In modern systems, cgroups (control groups) are commonly also used for this purpose.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

memory allocation

I would like to know how I could allocate some more memory to a process. Please note that I am not the root user. (1 Reply)
Discussion started by: sagar
1 Replies

2. UNIX for Advanced & Expert Users

threads and memory allocation

Hello! First of all, forgive me for bad English. When I starts new thread (pthread_create), system allocates some memory for it (for example, for thread's stack). I wonder when does it deallocate this memory? The problem is that I have a program which sometimes creates new threads and sometimes... (3 Replies)
Discussion started by: prankster
3 Replies

3. UNIX for Dummies Questions & Answers

HP-UX memory usage allocation

Hi all, I have a HP-UX Server with 4 gigabytes of physical RAM. When I use the 'Glance' utility to see what my memory utilization is, my memory usage shows up maxed out at 99%. I shut off all the known processes that I'm running on that box and the memory utilization is still at 78% (with Swap... (1 Reply)
Discussion started by: dehuang83
1 Replies

4. HP-UX

HP-UX memory usage allocation

Hi all, I have a HP-UX Server with 4 gigabytes of physical RAM. When I use the 'Glance' utility to see what my memory utilization is, my memory usage shows up maxed out at 99%. I shut off all the known processes that I'm running on that box and the memory utilization is still at 78% (with Swap... (3 Replies)
Discussion started by: dehuang83
3 Replies

5. Programming

memory allocation in subroutine

Hi everyone, I'm not new to C programming, but I'm having question regarding the memory allocation of a pointer variable which, for instance, will be declared in main(), but its memory will be allocated in subroutine. To clearify my question, I provide a small working example: #include... (1 Reply)
Discussion started by: MIB_Maik
1 Replies

6. Programming

Memory allocation in C

Hi Experts I need some help in static memory allocation in C. I have a program in which I declared 2 variables, one char array and one integer. I was little surprised to see the addresses of the variables. First: int x; char a; printf("%u %u\n', &x, a); I got the addresses displayed... (2 Replies)
Discussion started by: unx_freak
2 Replies

7. Shell Programming and Scripting

memory allocation to a variable

hello all.. i'm a beginner in shell scripting. I need to know what is really happening when we are creating a variable in shell scripting? how memory is allocated for that variable? (3 Replies)
Discussion started by: aarathy
3 Replies

8. HP-UX

Single Process Memory Allocation HP-UX 11i v3

Hi, I have HP-UX 11i v3 running on ia64. One of my application is 32-bit and I want to increase the memory allocation of this file upto 2GB. I am contentiously receiving an error message of Out of Memory. Can you please explain the procedure what kernel configuration( like maxdsize or... (1 Reply)
Discussion started by: ahmadamin416
1 Replies

9. Programming

C++/ROOT Memory Allocation?

Hello, I am new to C++ programming, so I'm still getting a feel for things. I recently wrote a simple C++ program (to be used as a ROOT Macro) to conduct a statistical analysis of a varied version of the Monty Hall problem (code below). Basically, the programs runs a few simple calculations to... (7 Replies)
Discussion started by: Tyler_92
7 Replies

10. UNIX for Dummies Questions & Answers

Memory allocation problem

I am using ubuntu. I have written a program to calculate prime factors. it works perfectly fine till entered number is less than 9989 (or so ) but when one enters a number higher than that, for example 15000, it does not work. Can anyone guide me whats the problem ? although new codes are welcome,... (2 Replies)
Discussion started by: Abhishek_kumar
2 Replies
BRK(2)							      BSD System Calls Manual							    BRK(2)

NAME
brk, sbrk -- change data segment size LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <sys/types.h> #include <unistd.h> int brk(const void *addr); void * sbrk(intptr_t incr); DESCRIPTION
The brk() and sbrk() functions are legacy interfaces from before the advent of modern virtual memory management. The brk() and sbrk() functions are used to change the amount of memory allocated in a process's data segment. They do this by moving the location of the ``break''. The break is the first address after the end of the process's uninitialized data segment (also known as the ``BSS''). The brk() function sets the break to addr. The sbrk() function raises the break by incr bytes, thus allocating at least incr bytes of new memory in the data segment. If incr is nega- tive, the break is lowered by incr bytes. NOTES
While the actual process data segment size maintained by the kernel will only grow or shrink in page sizes, these functions allow setting the break to unaligned values (i.e., it may point to any address inside the last page of the data segment). The current value of the program break may be determined by calling sbrk(0). See also end(3). The getrlimit(2) system call may be used to determine the maximum permissible size of the data segment. It will not be possible to set the break beyond ``etext + rlim.rlim_max'' where the rlim.rlim_max value is returned from a call to getrlimit(RLIMIT_DATA, &rlim). (See end(3) for the definition of etext). RETURN VALUES
The brk() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error. The sbrk() function returns the prior break value if successful; otherwise the value (void *)-1 is returned and the global variable errno is set to indicate the error. ERRORS
The brk() and sbrk() functions will fail if: [EINVAL] The requested break value was beyond the beginning of the data segment. [ENOMEM] The data segment size limit, as set by setrlimit(2), was exceeded. [ENOMEM] Insufficient space existed in the swap area to support the expansion of the data segment. SEE ALSO
execve(2), getrlimit(2), mmap(2), end(3), free(3), malloc(3) HISTORY
The brk() function appeared in Version 7 AT&T UNIX. BUGS
Mixing brk() or sbrk() with malloc(3), free(3), or similar functions will result in non-portable program behavior. Setting the break may fail due to a temporary lack of swap space. It is not possible to distinguish this from a failure caused by exceeding the maximum size of the data segment without consulting getrlimit(2). BSD
July 12, 1999 BSD
All times are GMT -4. The time now is 04:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy