09711f37 |
1 | // Created on: 2011-07-11 |
2 | // Created by: Kirill GAVRILOV |
3 | // Copyright (c) 2002-2014 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License 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. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
9df7f429 |
15 | |
16 | #ifndef NCollection_WinHeapAllocator_HeaderFile |
17 | #define NCollection_WinHeapAllocator_HeaderFile |
18 | |
19 | #include <NCollection_BaseAllocator.hxx> |
20 | |
21 | //! This memory allocator creates dedicated heap for allocations. |
22 | //! This technics available only on Windows platform |
23 | //! (no alternative on Unix systems). |
24 | //! It may be used to take control over memory fragmentation |
25 | //! because on destruction ALL allocated memory will be released |
26 | //! to the system. |
27 | //! |
28 | //! This allocator can also be created per each working thread |
29 | //! hovewer it real multi-threading performance is dubious. |
30 | //! |
31 | //! Notice that this also means that existing pointers will be broken |
32 | //! and you shoould control that allocator is alive along all objects |
33 | //! allocated with him. |
34 | class NCollection_WinHeapAllocator : public NCollection_BaseAllocator |
35 | { |
36 | public: |
37 | |
38 | //! Main constructor |
39 | Standard_EXPORT NCollection_WinHeapAllocator (const size_t theInitSizeBytes = 0x80000); |
40 | |
41 | //! Destructor |
42 | Standard_EXPORT virtual ~NCollection_WinHeapAllocator(); |
43 | |
44 | //! Allocate memory |
79104795 |
45 | Standard_EXPORT virtual void* Allocate (const Standard_Size theSize) Standard_OVERRIDE; |
9df7f429 |
46 | |
47 | //! Release memory |
79104795 |
48 | Standard_EXPORT virtual void Free (void* theAddress) Standard_OVERRIDE; |
9df7f429 |
49 | |
50 | // Declaration of CASCADE RTTI |
92efcf78 |
51 | DEFINE_STANDARD_RTTIEXT(NCollection_WinHeapAllocator,NCollection_BaseAllocator) |
9df7f429 |
52 | |
53 | private: |
54 | //! Copy constructor - prohibited |
55 | NCollection_WinHeapAllocator (const NCollection_WinHeapAllocator& ); |
56 | |
57 | private: |
58 | #if(defined(_WIN32) || defined(__WIN32__)) |
59 | void* myHeapH; |
60 | #endif |
61 | Standard_Boolean myToZeroMemory; |
62 | |
63 | }; |
64 | |
65 | // Definition of HANDLE object using Standard_DefineHandle.hxx |
66 | DEFINE_STANDARD_HANDLE (NCollection_WinHeapAllocator, NCollection_BaseAllocator) |
67 | |
68 | #endif //NCollection_WinHeapAllocator_HeaderFile |