source: icXML/icXML-devel/tests/src/MemHandlerTest/MemoryMonitor.hpp @ 2733

Last change on this file since 2733 was 2733, checked in by cameron, 6 years ago

More path fixes.

File size: 3.1 KB
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/*
19 * $Id: MemoryMonitor.hpp 698591 2008-09-24 14:35:36Z borisk $
20 */
21
22
23#include <xercesc/framework/MemoryManager.hpp>
24#include <icxercesc/util/PlatformUtils.hpp>
25#include <xercesc/dom/DOMLSParser.hpp>
26#include <xercesc/dom/DOMErrorHandler.hpp>
27#include <xercesc/dom/DOMError.hpp>
28#include <xercesc/dom/DOMImplementation.hpp>
29#include <xercesc/dom/DOMImplementationLS.hpp>
30#include <xercesc/dom/DOMImplementationRegistry.hpp>
31#include <icxercesc/parsers/AbstractDOMParser.hpp>
32#include <xercesc/sax2/XMLReaderFactory.hpp>
33#include <xercesc/sax2/SAX2XMLReader.hpp>
34#include <xercesc/sax/ErrorHandler.hpp>
35#include <xercesc/sax/SAXParseException.hpp>
36#include <icxercesc/parsers/SAXParser.hpp>
37#include "SimpleValueHashTableOf.hpp"
38
39XERCES_CPP_NAMESPACE_USE
40
41/**
42  * Configurable memory manager
43  *
44  * <p>This class is a memory manager implementation that keeps track of all
45  * allocations/deallocations to ensure that all memory that it allocated is
46  * deallocated.
47  * </p>
48  */
49
50class MemoryMonitor : public MemoryManager
51{
52public:
53
54    /** @name Constructor */
55    //@{
56
57    /**
58      * Default constructor
59      */
60    MemoryMonitor()
61    {
62      fHashTable = new SimpleValueHashTableOf<unsigned int>(1013);
63    }
64    //@}
65
66
67    /** @name Destructor */
68    //@{
69
70    /**
71      * Default destructor
72      */
73    virtual ~MemoryMonitor()
74    {
75      delete fHashTable;
76    }
77    //@}
78
79    virtual MemoryManager* getExceptionMemoryManager();
80
81    /** @name The virtual methods in MemoryManager */
82    //@{
83
84    /**
85      * This method allocates requested memory.
86      *
87      * @param size The requested memory size
88      *
89      * @return A pointer to the allocated memory
90      */
91    virtual void* allocate(XMLSize_t size);
92
93    /**
94      * This method deallocates memory
95      *
96      * @param p The pointer to the allocated memory to be deleted
97      */
98    virtual void deallocate(void* p);
99
100    //@}
101
102    // Print out amount of currently allocated memory
103    unsigned int getTotalMemory();
104
105private:
106    // -----------------------------------------------------------------------
107    //  Unimplemented constructors and operators
108    // -----------------------------------------------------------------------
109    MemoryMonitor(const MemoryMonitor &);
110    MemoryMonitor& operator=(const MemoryMonitor &);
111    SimpleValueHashTableOf<unsigned int>* fHashTable;
112
113};
Note: See TracBrowser for help on using the repository browser.