/[eiffelstudio]/FreeELKS/trunk/library/kernel/mem_info.e
ViewVC logotype

Contents of /FreeELKS/trunk/library/kernel/mem_info.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 91477 - (show annotations)
Sun Jan 14 09:47:13 2007 UTC (13 years ago) by ericb
File size: 3375 byte(s)
Synchronized with ISE 6.0.65740
1 indexing
2 description: "[
3 Properties of the memory management mechanism.
4 This class may be used as ancestor by classes needing its facilities.
5 ]"
6 library: "Free implementation of ELKS library"
7 copyright: "Copyright (c) 1986-2004, Eiffel Software and others"
8 license: "Eiffel Forum License v2 (see forum.txt)"
9 date: "$Date$"
10 revision: "$Revision$"
11
12 class MEM_INFO
13
14 inherit
15 MEMORY_STRUCTURE
16 rename
17 make as structure_make
18 export
19 {NONE} make_by_pointer, structure_make, item, shared
20 end
21
22 MEM_CONST
23
24 create
25 make
26
27 feature -- Initialization
28
29 make (memory: INTEGER) is
30 -- Update Current for `memory' type.
31 require
32 memory_valid: memory = Total_memory or memory = Eiffel_memory or memory = C_memory
33 do
34 structure_make
35 update (memory)
36 ensure
37 type_set: type = memory
38 end
39
40 update (memory: INTEGER) is
41 -- Update Current for `memory' type.
42 require
43 memory_valid: memory = Total_memory or memory = Eiffel_memory or memory = C_memory
44 do
45 mem_stat (item, memory)
46 type := memory
47 ensure
48 type_set: type = memory
49 end
50
51 feature -- Access
52
53 type: INTEGER
54 -- Memory type (Total, Eiffel, C)
55
56 feature -- Measurement
57
58 total: INTEGER is
59 -- Total number of bytes allocated for `type'
60 -- before last call to `update'
61 do
62 Result := c_ml_total (item)
63 end
64
65 used: INTEGER is
66 -- Number of bytes used for `type'
67 -- before last call to `update'
68 do
69 Result := c_ml_used (item)
70 end
71
72 free: INTEGER is
73 -- Number of bytes still free for `type'
74 -- before last call to `update'
75 do
76 Result := total - used - overhead
77 ensure
78 Computed: Result = total - used - overhead
79 end
80
81 overhead: INTEGER is
82 -- Number of bytes used by memory management
83 -- scheme for `type' before last call to `update'
84 do
85 Result := c_ml_over (item)
86 end
87
88 chunk: INTEGER is
89 -- Number of allocated memory chunks
90 do
91 Result := c_ml_chunk (item)
92 end
93
94 feature {NONE} -- Implementation
95
96 mem_stat (a_ptr: POINTER; mem: INTEGER) is
97 -- Initialize `a_ptr' used by MEM_INFO to retrieve the
98 -- statistics frozen at the time of this call.
99 external
100 "C use %"eif_memory.h%""
101 alias
102 "eif_mem_stat"
103 end
104
105 structure_size: INTEGER is
106 -- Size of underlying C structure.
107 do
108 Result := c_sizeof_emallinfo
109 end
110
111 feature {NONE} -- C externals
112
113 c_ml_total (a_ptr: POINTER): INTEGER is
114 -- Access `ml_total' data member of `a_ptr' struct.
115 external
116 "C inline use %"eif_memory.h%""
117 alias
118 "return ((struct emallinfo *) $a_ptr)->ml_total;"
119 end
120
121 c_ml_used (a_ptr: POINTER): INTEGER is
122 -- Access `ml_used' data member of `a_ptr' struct.
123 external
124 "C inline use %"eif_memory.h%""
125 alias
126 "return ((struct emallinfo *) $a_ptr)->ml_used;"
127 end
128
129 c_ml_over (a_ptr: POINTER): INTEGER is
130 -- Access `ml_over' data member of `a_ptr' struct.
131 external
132 "C inline use %"eif_memory.h%""
133 alias
134 "return ((struct emallinfo *) $a_ptr)->ml_over;"
135 end
136
137 c_ml_chunk (a_ptr: POINTER): INTEGER is
138 -- Access `ml_chunk' data member of `a_ptr' struct.
139 external
140 "C inline use %"eif_memory.h%""
141 alias
142 "return ((struct emallinfo *) $a_ptr)->ml_chunk;"
143 end
144
145 c_sizeof_emallinfo: INTEGER is
146 -- Size of struct `emallinfo'.
147 external
148 "C inline use %"eif_memory.h%""
149 alias
150 "return sizeof(struct emallinfo);"
151 end
152
153 invariant
154
155 consistent_memory: total = free + used + overhead
156
157 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23