My Project
Loading...
Searching...
No Matches
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 ( void  )

Definition at line 112 of file omStats.c.

113{
114 omUpdateInfo();
115 return om_Info;
116}
void omUpdateInfo()
Definition: omStats.c:27
omInfo_t om_Info
Definition: omStats.c:16

◆ omInitInfo()

void omInitInfo ( void  )

Definition at line 20 of file omStats.c.

21{
22#ifdef HAVE_SBRK
23 om_SbrkInit = (unsigned long) sbrk(0);
24#endif
25}
unsigned long om_SbrkInit
Definition: omStats.c:18

◆ omPrintInfo()

void omPrintInfo ( FILE *  fd)

Definition at line 132 of file omStats.c.

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

◆ omPrintStats()

void omPrintStats ( FILE *  fd)

Definition at line 118 of file omStats.c.

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

◆ omUpdateInfo()

void omUpdateInfo ( void  )

Definition at line 27 of file omStats.c.

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

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 16 of file omStats.c.

◆ om_SbrkInit

unsigned long om_SbrkInit = 0

Definition at line 18 of file omStats.c.