Files
oldlinux-files/Minix/2.0.0/wwwman/man1/chmem.1.html
2024-02-19 00:21:39 -05:00

72 lines
2.5 KiB
HTML

<HTML>
<HEAD>
<TITLE>chmem(1)</TITLE>
</HEAD>
<BODY>
<H1>chmem(1)</H1>
<HR>
<PRE>
</PRE>
<H2>NAME</H2><PRE>
chmem - change memory allocation
</PRE>
<H2>SYNOPSIS</H2><PRE>
<STRONG>chmem</STRONG> [<STRONG>+</STRONG>] [<STRONG>-</STRONG>] [<STRONG>=</STRONG>] <EM>amount</EM> <EM>file</EM>
</PRE>
<H2>EXAMPLES</H2><PRE>
<STRONG>chmem</STRONG> <STRONG>=50000</STRONG> <STRONG>a.out</STRONG> # Give <EM>a</EM>.<EM>out</EM> 50K of stack space
<STRONG>chmem</STRONG> <STRONG>-4000</STRONG> <STRONG>a.out</STRONG> # Reduce the stack space by 4000 bytes
<STRONG>chmem</STRONG> <STRONG>+1000</STRONG> <STRONG>file1</STRONG> # Increase each stack by 1000 bytes
</PRE>
<H2>DESCRIPTION</H2><PRE>
When a program is loaded into memory, it is allocated enough memory for
the text and data+bss segments, plus an area for the stack. Data segment
growth using <EM>malloc</EM> , <EM>brk</EM> , or <EM>sbrk</EM> eats up stack space from the low end.
The amount of stack space to allocate is derived from a field in the
executable program's file header. If the combined stack and data segment
growth exceeds the stack space allocated, the program will be terminated.
It is therefore important to set the amount of stack space carefully. If
too little is provided, the program may crash. If too much is provided,
memory will be wasted, and fewer programs will be able to fit in memory
and run simultaneously. MINIX does not swap, so that when memory is
full, subsequent attempts to fork will fail. The compiler sets the stack
space to the largest possible value (for the Intel CPUs, 64K - text -
data). For many programs, this value is far too large. Nonrecursive
programs that do not call <EM>brk</EM> , <EM>sbrk</EM> , or <EM>malloc</EM> , and do not have any
local arrays usually do not need more than 8K of stack space.
The <EM>chmem</EM> command changes the value of the header field that determines
the stack allocation, and thus indirectly the total memory required to
run the program. The = option sets the stack size to a specific value;
the + and - options increment and decrement the current value by the
indicated amount. The old and new stack sizes are printed.
</PRE>
<H2>SEE ALSO</H2><PRE>
<STRONG><A HREF="../man1/install.1.html">install(1)</A></STRONG>, <STRONG><A HREF="../man2/brk.2.html">brk(2)</A></STRONG>.
</PRE>
</BODY>
</HTML>