Data Structures | Functions | Variables
omStats.h File Reference

Go to the source code of this file.

Data Structures

struct  omInfo_t
 

Functions

struct omInfo_s omGetInfo ()
 
void omUpdateInfo ()
 
void omInitInfo ()
 
void omPrintStats (FILE *fd)
 
void omPrintInfo (FILE *fd)
 

Variables

struct omInfo_s om_Info
 
unsigned long om_SbrkInit
 

Data Structure Documentation

struct omInfo_s

Definition at line 10 of file omStats.h.

Data Fields
long AvailBytes
long AvailBytesFromValloc
long AvailBytesMalloc
long AvailPages
long CurrentBytesFromMalloc
long CurrentBytesFromValloc
long CurrentBytesMmap
long CurrentBytesSbrk
long CurrentBytesSystem
long CurrentRegionsAlloc
long MaxBytesFromMalloc
long MaxBytesFromValloc
long MaxBytesMmap
long MaxBytesSbrk
long MaxBytesSystem
long MaxPages
long MaxRegionsAlloc
long UsedBytes
long UsedBytesFromValloc
long UsedBytesMalloc
long UsedPages

Function Documentation

struct omInfo_s omGetInfo ( )

Definition at line 108 of file omStats.c.

109 {
110  omUpdateInfo();
111  return om_Info;
112 }
omInfo_t om_Info
Definition: omStats.c:13
void omUpdateInfo()
Definition: omStats.c:24
void omInitInfo ( )

Definition at line 17 of file omStats.c.

18 {
19 #ifdef HAVE_SBRK
20  om_SbrkInit = (unsigned long) sbrk(0);
21 #endif
22 }
unsigned long om_SbrkInit
Definition: omStats.c:15
void omPrintInfo ( FILE *  fd)

Definition at line 127 of file omStats.c.

128 {
129  omUpdateInfo();
130  fprintf(fd, " Current: Max:\n");
131  fprintf(fd, "BytesSystem: %8ldk %8ldk\n", om_Info.CurrentBytesSystem/1024, om_Info.MaxBytesSystem/1024);
132  fprintf(fd, "BytesSbrk: %8ldk %8ldk\n", om_Info.CurrentBytesSbrk/1024, om_Info.MaxBytesSbrk/1024);
133  fprintf(fd, "BytesMmap: %8ldk %8ldk\n", om_Info.CurrentBytesMmap/1024, om_Info.MaxBytesMmap/1024);
134  fprintf(fd, "BytesFromMalloc: %8ldk %8ldk\n", om_Info.CurrentBytesFromMalloc/1024, om_Info.MaxBytesFromMalloc/1024);
135  fprintf(fd, "BytesFromValloc: %8ldk %8ldk\n", om_Info.CurrentBytesFromValloc/1024, om_Info.MaxBytesFromValloc/1024);
136  fprintf(fd, "PagesAlloc: %8ld %8ld \n", om_Info.UsedPages, om_Info.MaxPages);
137  fprintf(fd, "RegionsAlloc: %8ld %8ld \n", om_Info.CurrentRegionsAlloc, om_Info.MaxRegionsAlloc);
138  fprintf(fd, " Used: Avail:\n");
139  fprintf(fd, "BytesAppl: %8ldk %8ldk\n", om_Info.UsedBytes/1024, om_Info.AvailBytes/1024);
140  fprintf(fd, "BytesMalloc: %8ldk %8ldk\n", om_Info.UsedBytesMalloc/1024, om_Info.AvailBytesMalloc/1024);
141  fprintf(fd, "BytesValloc: %8ldk %8ldk\n", om_Info.UsedBytesFromValloc/1024, om_Info.AvailBytesFromValloc/1024);
142  fprintf(fd, "Pages: %8ld %8ld\n", om_Info.UsedPages, om_Info.AvailPages);
143 }
int status int fd
Definition: si_signals.h:59
omInfo_t om_Info
Definition: omStats.c:13
void omUpdateInfo()
Definition: omStats.c:24
void omPrintStats ( FILE *  fd)

Definition at line 114 of file omStats.c.

115 {
116  omUpdateInfo();
117  fprintf(fd, "System %ldk:%ldk Appl %ldk/%ldk Malloc %ldk/%ldk Valloc %ldk/%ldk Pages %ld/%ld Regions %ld:%ld\n",
118  om_Info.CurrentBytesSystem/1024, om_Info.MaxBytesSystem/1024,
119  om_Info.UsedBytes/1024, om_Info.AvailBytes/1024,
120  om_Info.UsedBytesMalloc/1024, om_Info.AvailBytesMalloc/1024,
121  om_Info.CurrentBytesFromValloc/1024, om_Info.AvailBytesFromValloc/1024,
122  om_Info.UsedPages, om_Info.AvailPages,
123  om_Info.CurrentRegionsAlloc, om_Info.MaxRegionsAlloc);
124 }
int status int fd
Definition: si_signals.h:59
omInfo_t om_Info
Definition: omStats.c:13
void omUpdateInfo()
Definition: omStats.c:24
void omUpdateInfo ( )

Definition at line 24 of file omStats.c.

25 {
26 #ifdef OM_MALLOC_UPDATE_INFO
27  OM_MALLOC_UPDATE_INFO;
28 #endif
29 
30  /* this can happen, since sizes are added as requested, and
31  subtracted as the real size of the memory */
32  if (om_Info.CurrentBytesFromMalloc < 0)
33  om_Info.CurrentBytesFromMalloc = 0;
34 
35  om_Info.UsedBytesFromValloc = omGetUsedBinBytes();
36  om_Info.AvailBytesFromValloc = om_Info.CurrentBytesFromValloc - om_Info.UsedBytesFromValloc;
37 
38 #ifdef OM_MALLOC_USED_BYTES
39  om_Info.UsedBytesMalloc = OM_MALLOC_USED_BYTES;
40 #else
41  om_Info.UsedBytesMalloc = om_Info.CurrentBytesFromMalloc;
42 #endif
43 #ifdef OM_MALLOC_AVAIL_BYTES
44  om_Info.AvailBytesMalloc = OM_MALLOC_AVAIL_BYTES;
45 #endif
46 
47  om_Info.UsedBytes = om_Info.UsedBytesMalloc + om_Info.UsedBytesFromValloc;
48  om_Info.AvailBytes = om_Info.AvailBytesMalloc + om_Info.AvailBytesFromValloc;
49 
50 #ifdef OM_HAVE_VALLOC_MMAP
51  om_Info.CurrentBytesMmap = om_Info.CurrentBytesFromValloc;
52  om_Info.MaxBytesMmap = om_Info.MaxBytesFromValloc;
53 #endif
54 #ifdef OM_MALLOC_CURRENT_BYTES_MMAP
55  om_Info.CurrentBytesMmap += OM_MALLOC_CURRENT_BYTES_MMAP;
56 #endif
57 #ifdef OM_MALLOC_MAX_BYTES_MMAP
58  om_Info.MaxBytesMmap += OM_MALLOC_MAX_BYTES_MMAP;
59 #endif
60 
61 #ifndef OM_MALLOC_CURRENT_BYTES_SBRK
62 #ifdef HAVE_SBRK
63  if (om_SbrkInit)
64  {
65  om_Info.CurrentBytesSbrk = (unsigned long) sbrk(0) - om_SbrkInit;
66  if (om_Info.CurrentBytesSbrk > om_Info.MaxBytesSbrk)
67  om_Info.MaxBytesSbrk = om_Info.CurrentBytesSbrk;
68  }
69  else
70  {
71  om_SbrkInit = (unsigned long) sbrk(0);
72  }
73 #endif
74 #else
75  om_Info.CurrentBytesSbrk = OM_MALLOC_CURRENT_BYTES_SBRK;
76 #ifdef OM_MALLOC_MAX_BYTES_SBRK
77  om_Info.MaxBytesSbrk = OM_MALLOC_MAX_BYTES_SBRK;
78 #else
79  if (om_Info.CurrentBytesSbrk > om_Info.MaxBytesSbrk)
80  om_Info.MaxBytesSbrk = om_Info.CurrentBytesSbrk;
81 #endif
82 #endif
83 
84 #ifdef OM_MALLOC_CURRENT_BYTES_SYSTEM
85  om_Info.CurrentBytesSystem = OM_MALLOC_CURRENT_BYTES_SYSTEM;
86 #else
87  om_Info.CurrentBytesSystem =
88  (om_Info.CurrentBytesSbrk > om_Info.UsedBytesMalloc ?
89  om_Info.CurrentBytesSbrk : om_Info.UsedBytesMalloc);
90 #endif
91 #ifdef OM_HAVE_VALLOC_MMAP
92  om_Info.CurrentBytesSystem += om_Info.CurrentBytesFromValloc;
93 #endif
94 
95 #if ! (defined(OM_HAVE_VALLOC_MMAP) && defined(OM_MALLOC_MAX_BYTES_SYSTEM))
96 #ifdef OM_MALLOC_MAX_BYTES_SYSTEM
97  om_Info.MaxBytesSystem = OM_MALLOC_MAX_BYTES_SYSTEM;
98 #else
99  om_Info.MaxBytesSystem =
100  (om_Info.MaxBytesSbrk + om_Info.MaxBytesMmap >
101  om_Info.MaxBytesFromMalloc + om_Info.MaxBytesFromValloc ?
102  om_Info.MaxBytesSbrk + om_Info.MaxBytesMmap :
103  om_Info.MaxBytesFromMalloc + om_Info.MaxBytesFromValloc);
104 #endif
105 #endif
106 }
unsigned long om_SbrkInit
Definition: omStats.c:15
long omGetUsedBinBytes()
Definition: omBin.c:760
omInfo_t om_Info
Definition: omStats.c:13

Variable Documentation

struct omInfo_s om_Info

Definition at line 13 of file omStats.c.

unsigned long om_SbrkInit

Definition at line 15 of file omStats.c.