/[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 91424 - (show annotations)
Tue Oct 26 18:39:32 2004 UTC (15 years, 2 months ago) by manus_eiffel
File size: 4097 byte(s)
Initial revision

1 indexing
2
3 description: "[
4 Properties of the memory management mechanism.
5 This class may be used as ancestor by classes needing its facilities.
6 ]"
7
8 status: "See notice at end of class"
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 end
102
103 structure_size: INTEGER is
104 -- Size of underlying C structure.
105 do
106 Result := c_sizeof_emallinfo
107 end
108
109 feature {NONE} -- C externals
110
111 c_ml_total (a_ptr: POINTER): INTEGER is
112 -- Access `ml_total' data member of `a_ptr' struct.
113 external
114 "C inline use %"eif_eiffel.h%""
115 alias
116 "((struct emallinfo *) $a_ptr)->ml_total"
117 end
118
119 c_ml_used (a_ptr: POINTER): INTEGER is
120 -- Access `ml_used' data member of `a_ptr' struct.
121 external
122 "C inline use %"eif_eiffel.h%""
123 alias
124 "((struct emallinfo *) $a_ptr)->ml_used"
125 end
126
127 c_ml_over (a_ptr: POINTER): INTEGER is
128 -- Access `ml_over' data member of `a_ptr' struct.
129 external
130 "C inline use %"eif_eiffel.h%""
131 alias
132 "((struct emallinfo *) $a_ptr)->ml_over"
133 end
134
135 c_ml_chunk (a_ptr: POINTER): INTEGER is
136 -- Access `ml_chunk' data member of `a_ptr' struct.
137 external
138 "C inline use %"eif_eiffel.h%""
139 alias
140 "((struct emallinfo *) $a_ptr)->ml_chunk"
141 end
142
143 c_sizeof_emallinfo: INTEGER is
144 -- Size of struct `emallinfo'.
145 external
146 "C macro use %"eif_eiffel.h%""
147 alias
148 "sizeof(struct emallinfo)"
149 end
150
151 invariant
152
153 consistent_memory: total = free + used + overhead
154
155 indexing
156
157 library: "[
158 EiffelBase: Library of reusable components for Eiffel.
159 ]"
160
161 status: "[
162 Copyright 1986-2001 Interactive Software Engineering (ISE).
163 For ISE customers the original versions are an ISE product
164 covered by the ISE Eiffel license and support agreements.
165 ]"
166
167 license: "[
168 EiffelBase may now be used by anyone as FREE SOFTWARE to
169 develop any product, public-domain or commercial, without
170 payment to ISE, under the terms of the ISE Free Eiffel Library
171 License (IFELL) at http://eiffel.com/products/base/license.html.
172 ]"
173
174 source: "[
175 Interactive Software Engineering Inc.
176 ISE Building
177 360 Storke Road, Goleta, CA 93117 USA
178 Telephone 805-685-1006, Fax 805-685-6869
179 Electronic mail <info@eiffel.com>
180 Customer support http://support.eiffel.com
181 ]"
182
183 info: "[
184 For latest info see award-winning pages: http://eiffel.com
185 ]"
186
187 end -- class MEM_INFO
188
189
190

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23