1 // Created on: 2005-03-15
2 // Created by: Peter KURNEV
3 // Copyright (c) 2005-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and / or modify it
8 // under the terms of the GNU Lesser General Public version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _Standard_MMgrRoot_HeaderFile
17 #define _Standard_MMgrRoot_HeaderFile
19 #ifndef _Standard_Address_HeaderFile
20 #include <Standard_Address.hxx>
22 #ifndef _Standard_Integer_HeaderFile
23 #include <Standard_Integer.hxx>
25 #ifndef _Standard_Macro_HeaderFile
26 #include <Standard_Macro.hxx>
30 * Root class for Open CASCADE mmemory managers.
31 * Defines only abstract interface functions.
34 class Standard_MMgrRoot
38 //! Virtual destructor; required for correct inheritance
39 Standard_EXPORT virtual ~Standard_MMgrRoot();
41 //! Allocate specified number of bytes.
42 //! The actually allocated space should be rounded up to
43 //! double word size (4 bytes), as this is expected by implementation
44 //! of some classes in OCC (e.g. TCollection_AsciiString)
45 Standard_EXPORT virtual Standard_Address Allocate (const Standard_Size theSize)=0;
47 //! Reallocate previously allocated memory to contain at least theSize bytes.
48 //! In case of success, aPtr should be nullified and new pointer returned.
49 Standard_EXPORT virtual Standard_Address Reallocate (Standard_Address& aPtr,
50 const Standard_Size theSize)=0;
52 //! Frees previously allocated memory at specified address.
53 //! The pointer is nullified.
54 Standard_EXPORT virtual void Free(Standard_Address& aPtr)=0;
56 //! Purge internally cached unused memory blocks (if any)
57 //! by releasing them to the operating system.
58 //! Must return non-zero if some memory has been actually released,
59 //! or zero otherwise.
61 //! If option isDestroyed is True, this means that memory
62 //! manager is not expected to be used any more; note however
63 //! that in general case it is still possible to have calls to that
64 //! instance of memory manager after this (e.g. to free memory
65 //! of static objects in OCC). Thus this option should
66 //! command the memory manager to release any cached memory
67 //! to the system and not cache any more, but still remain operable...
69 //! Default implementation does nothing and returns 0.
70 Standard_EXPORT virtual Standard_Integer Purge(Standard_Boolean isDestroyed=Standard_False);