My Project  debian-1:4.1.1-p2+ds-4build3
Functions | Variables
omStats.c File Reference
#include <unistd.h>
#include "omConfig.h"
#include "omDefaultConfig.h"
#include "omMalloc.h"
#include "omalloc.h"

Go to the source code of this file.

Functions

void omInitInfo ()
 
void omUpdateInfo ()
 
omInfo_t omGetInfo ()
 
void omPrintStats (FILE *fd)
 
void omPrintInfo (FILE *fd)
 

Variables

omInfo_t om_Info = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
 
unsigned long om_SbrkInit = 0
 

Function Documentation

◆ omGetInfo()

omInfo_t omGetInfo ( )

Definition at line 109 of file omStats.c.

110 {
111  omUpdateInfo();
112  return om_Info;
113 }

◆ omInitInfo()

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 }

◆ omPrintInfo()

void omPrintInfo ( FILE *  fd)

Definition at line 129 of file omStats.c.

130 {
131  omUpdateInfo();
132  fputs(" Current: Max:\n",fd);
133  fprintf(fd, "BytesSystem: %8ldk %8ldk\n", om_Info.CurrentBytesSystem/1024, om_Info.MaxBytesSystem/1024);
134  fprintf(fd, "BytesSbrk: %8ldk %8ldk\n", om_Info.CurrentBytesSbrk/1024, om_Info.MaxBytesSbrk/1024);
135  fprintf(fd, "BytesMmap: %8ldk %8ldk\n", om_Info.CurrentBytesMmap/1024, om_Info.MaxBytesMmap/1024);
136  fprintf(fd, "BytesFromMalloc: %8ldk %8ldk\n", om_Info.CurrentBytesFromMalloc/1024, om_Info.MaxBytesFromMalloc/1024);
137  fprintf(fd, "BytesFromValloc: %8ldk %8ldk\n", om_Info.CurrentBytesFromValloc/1024, om_Info.MaxBytesFromValloc/1024);
138  fprintf(fd, "PagesAlloc: %8ld %8ld \n", om_Info.UsedPages, om_Info.MaxPages);
139  fprintf(fd, "RegionsAlloc: %8ld %8ld \n", om_Info.CurrentRegionsAlloc, om_Info.MaxRegionsAlloc);
140  fputs(" Used: Avail:\n",fd);
141  fprintf(fd, "BytesAppl: %8ldk %8ldk\n", om_Info.UsedBytes/1024, om_Info.AvailBytes/1024);
142  fprintf(fd, "BytesMalloc: %8ldk %8ldk\n", om_Info.UsedBytesMalloc/1024, om_Info.AvailBytesMalloc/1024);
143  fprintf(fd, "BytesValloc: %8ldk %8ldk\n", om_Info.UsedBytesFromValloc/1024, om_Info.AvailBytesFromValloc/1024);
144  fprintf(fd, "Pages: %8ld %8ld\n", om_Info.UsedPages, om_Info.AvailPages);
145 }

◆ omPrintStats()

void omPrintStats ( FILE *  fd)

Definition at line 115 of file omStats.c.

116 {
117  omUpdateInfo();
118  fprintf(fd, "System %ldk:%ldk Appl %ldk/%ldk Malloc %ldk/%ldk Valloc %ldk/%ldk Pages %ld/%ld Regions %ld:%ld Internal: %ld\n",
119  om_Info.CurrentBytesSystem/1024, om_Info.MaxBytesSystem/1024,
120  om_Info.UsedBytes/1024, om_Info.AvailBytes/1024,
121  om_Info.UsedBytesMalloc/1024, om_Info.AvailBytesMalloc/1024,
122  om_Info.CurrentBytesFromValloc/1024, om_Info.AvailBytesFromValloc/1024,
123  om_Info.UsedPages, om_Info.AvailPages,
124  om_Info.CurrentRegionsAlloc, om_Info.MaxRegionsAlloc,
125  om_Info.InternalUsedBytesMalloc);
126 }

◆ omUpdateInfo()

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  -om_Info.InternalUsedBytesMalloc;
43 #endif
44 #ifdef OM_MALLOC_AVAIL_BYTES
45  om_Info.AvailBytesMalloc = OM_MALLOC_AVAIL_BYTES;
46 #endif
47 
48  om_Info.UsedBytes = om_Info.UsedBytesMalloc + om_Info.UsedBytesFromValloc;
49  om_Info.AvailBytes = om_Info.AvailBytesMalloc + om_Info.AvailBytesFromValloc;
50 
51 #ifdef OM_HAVE_VALLOC_MMAP
52  om_Info.CurrentBytesMmap = om_Info.CurrentBytesFromValloc;
53  om_Info.MaxBytesMmap = om_Info.MaxBytesFromValloc;
54 #endif
55 #ifdef OM_MALLOC_CURRENT_BYTES_MMAP
56  om_Info.CurrentBytesMmap += OM_MALLOC_CURRENT_BYTES_MMAP;
57 #endif
58 #ifdef OM_MALLOC_MAX_BYTES_MMAP
59  om_Info.MaxBytesMmap += OM_MALLOC_MAX_BYTES_MMAP;
60 #endif
61 
62 #ifndef OM_MALLOC_CURRENT_BYTES_SBRK
63 #ifdef HAVE_SBRK
64  if (om_SbrkInit)
65  {
66  om_Info.CurrentBytesSbrk = (unsigned long) sbrk(0) - om_SbrkInit;
67  if (om_Info.CurrentBytesSbrk > om_Info.MaxBytesSbrk)
68  om_Info.MaxBytesSbrk = om_Info.CurrentBytesSbrk;
69  }
70  else
71  {
72  om_SbrkInit = (unsigned long) sbrk(0);
73  }
74 #endif
75 #else
76  om_Info.CurrentBytesSbrk = OM_MALLOC_CURRENT_BYTES_SBRK;
77 #ifdef OM_MALLOC_MAX_BYTES_SBRK
78  om_Info.MaxBytesSbrk = OM_MALLOC_MAX_BYTES_SBRK;
79 #else
80  if (om_Info.CurrentBytesSbrk > om_Info.MaxBytesSbrk)
81  om_Info.MaxBytesSbrk = om_Info.CurrentBytesSbrk;
82 #endif
83 #endif
84 
85 #ifdef OM_MALLOC_CURRENT_BYTES_SYSTEM
86  om_Info.CurrentBytesSystem = OM_MALLOC_CURRENT_BYTES_SYSTEM;
87 #else
88  om_Info.CurrentBytesSystem =
89  (om_Info.CurrentBytesSbrk > om_Info.UsedBytesMalloc ?
90  om_Info.CurrentBytesSbrk : om_Info.UsedBytesMalloc);
91 #endif
92 #ifdef OM_HAVE_VALLOC_MMAP
93  om_Info.CurrentBytesSystem += om_Info.CurrentBytesFromValloc;
94 #endif
95 
96 #if ! (defined(OM_HAVE_VALLOC_MMAP) && defined(OM_MALLOC_MAX_BYTES_SYSTEM))
97 #ifdef OM_MALLOC_MAX_BYTES_SYSTEM
98  om_Info.MaxBytesSystem = OM_MALLOC_MAX_BYTES_SYSTEM;
99 #else
100  om_Info.MaxBytesSystem =
101  (om_Info.MaxBytesSbrk + om_Info.MaxBytesMmap >
102  om_Info.MaxBytesFromMalloc + om_Info.MaxBytesFromValloc ?
103  om_Info.MaxBytesSbrk + om_Info.MaxBytesMmap :
104  om_Info.MaxBytesFromMalloc + om_Info.MaxBytesFromValloc);
105 #endif
106 #endif
107 }

Variable Documentation

◆ om_Info

omInfo_t om_Info = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

Definition at line 13 of file omStats.c.

◆ om_SbrkInit

unsigned long om_SbrkInit = 0

Definition at line 15 of file omStats.c.

om_SbrkInit
unsigned long om_SbrkInit
Definition: omStats.c:15
om_Info
omInfo_t om_Info
Definition: omStats.c:13
omGetUsedBinBytes
long omGetUsedBinBytes()
Definition: omBin.c:761
fd
int status int fd
Definition: si_signals.h:59
omUpdateInfo
void omUpdateInfo()
Definition: omStats.c:24