Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:20

0001 // Created on: 2011-07-11
0002 // Created by: Kirill GAVRILOV
0003 // Copyright (c) 2002-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef NCollection_WinHeapAllocator_HeaderFile
0017 #define NCollection_WinHeapAllocator_HeaderFile
0018 
0019 #include <NCollection_BaseAllocator.hxx>
0020 
0021 //! This memory allocator creates dedicated heap for allocations.
0022 //! This technics available only on Windows platform
0023 //! (no alternative on Unix systems).
0024 //! It may be used to take control over memory fragmentation
0025 //! because on destruction ALL allocated memory will be released
0026 //! to the system.
0027 //!
0028 //! This allocator can also be created per each working thread
0029 //! hovewer it real multi-threading performance is dubious.
0030 //!
0031 //! Notice that this also means that existing pointers will be broken
0032 //! and you shoould control that allocator is alive along all objects
0033 //! allocated with him.
0034 class NCollection_WinHeapAllocator : public NCollection_BaseAllocator
0035 {
0036 public:
0037 
0038   //! Main constructor
0039   Standard_EXPORT NCollection_WinHeapAllocator (const size_t theInitSizeBytes = 0x80000);
0040 
0041   //! Destructor
0042   Standard_EXPORT virtual ~NCollection_WinHeapAllocator();
0043 
0044   //! Allocate memory
0045   Standard_EXPORT virtual void* Allocate (const Standard_Size theSize) Standard_OVERRIDE;
0046 
0047   //! Allocate memory
0048   void* AllocateOptimal(const Standard_Size theSize) Standard_OVERRIDE { return Allocate(theSize); }
0049 
0050   //! Release memory
0051   Standard_EXPORT virtual void  Free (void* theAddress) Standard_OVERRIDE;
0052 
0053   // Declaration of CASCADE RTTI
0054   DEFINE_STANDARD_RTTIEXT(NCollection_WinHeapAllocator,NCollection_BaseAllocator)
0055 
0056 private:
0057   //! Copy constructor - prohibited
0058   NCollection_WinHeapAllocator (const NCollection_WinHeapAllocator& );
0059 
0060 private:
0061 #if(defined(_WIN32) || defined(__WIN32__))
0062   void* myHeapH;
0063 #endif
0064   Standard_Boolean myToZeroMemory;
0065 
0066 };
0067 
0068 // Definition of HANDLE object using Standard_DefineHandle.hxx
0069 DEFINE_STANDARD_HANDLE (NCollection_WinHeapAllocator, NCollection_BaseAllocator)
0070 
0071 #endif //NCollection_WinHeapAllocator_HeaderFile