blob: 0621925f24b78f3cb7d00f3c462662995767692a [file] [log] [blame]
Zesstra7ea4a032019-11-26 20:11:40 +01001SYNOPSIS
2 void low_memory(int what, int limitvalue, int memory, int reservestate)
3
4DESCRIPTION
5 This efun is called when there is a (potential) low-memory situation.
6 Two different limits for the amount of allocated memory can be
7 configured: a soft limit and a hard limit. If the soft limit is
8 exceeded, the driver calls low_memory() but does nothing else.
9 If the hard limit is exceeded, the driver calls low_memory() as well,
10 but initiates a garbage collection directly after the call. The efun
11 is called as well directly before a user-initiated garbage collection
12 is started.
13
14 <what> denotes the type of limit which was exceeded:
15 - NO_MALLOC_LIMIT_EXCEEDED (0)
16 No limit was exceeded, but a garbage collection was requested by a
17 call to garbage_collection() and it will begin right after
18 low_memory() returns.
19 - SOFT_MALLOC_LIMIT_EXCEEDED (1)
20 The soft limit was exceeded.
21 - HARD_MALLOC_LIMIT_EXCEEDED (2)
22 The hard limit was exceeded. A garbage collection will begin right
23 after low_memory() returns.
24
25 <limit> specifies the numerical value of the limit which was exceeded.
26 It is 0 in case of NO_MALLOC_LIMIT_EXCEEDED.
27
28 <memory> specifies the amount of allocated memory right now.
29
30 <reservestate> specifies the current state of the memory reserves of
31 the driver. The states of the 3 different reserves are OR'ed together.
32 - USER_RESERVE_AVAILABLE (1)
33 The user reserve is available.
34 - MASTER_RESERVE_AVAILABLE (2)
35 The master reserve is available.
36 - SYSTEM_RESERVE_AVAILABLE (4)
37 The system reserve is available.
38
39 This efun might be used to inform users about the garbage collection
40 and the expected long lag.
41
42 Another possibility is to initiate a garbage collection deliberately
43 at a suitable time (e.g. during the following night) after the soft
44 limit was hit.
45
46REMARKS
47 If in a low_memory condition when the memory reserves have been used
48 already and they could not be re-allocated after a garbage collection
49 slow_shut_down() is called instead of calling this function again.
50
51HISTORY
52 Introduced in 3.3.719
53
54SEE ALSO
55 debug_info(E), garbage_collection(E), slow_shut_down(M), memory(C)
56 malloc(D)