0022859: Developers guide with code samples
[occt.git] / src / NCollection / NCollection_WinHeapAllocator.hxx
CommitLineData
9df7f429 1// File: NCollection_WinHeapAllocator.hxx
2// Created: 22.07.11
3// Author: Kirill GAVRILOV
4// Copyright: Open Cascade 2011
5
6#ifndef NCollection_WinHeapAllocator_HeaderFile
7#define NCollection_WinHeapAllocator_HeaderFile
8
9#include <NCollection_BaseAllocator.hxx>
10
11//! This memory allocator creates dedicated heap for allocations.
12//! This technics available only on Windows platform
13//! (no alternative on Unix systems).
14//! It may be used to take control over memory fragmentation
15//! because on destruction ALL allocated memory will be released
16//! to the system.
17//!
18//! This allocator can also be created per each working thread
19//! hovewer it real multi-threading performance is dubious.
20//!
21//! Notice that this also means that existing pointers will be broken
22//! and you shoould control that allocator is alive along all objects
23//! allocated with him.
24class NCollection_WinHeapAllocator : public NCollection_BaseAllocator
25{
26public:
27
28 //! Main constructor
29 Standard_EXPORT NCollection_WinHeapAllocator (const size_t theInitSizeBytes = 0x80000);
30
31 //! Destructor
32 Standard_EXPORT virtual ~NCollection_WinHeapAllocator();
33
34 //! Allocate memory
35 Standard_EXPORT virtual void* Allocate (const Standard_Size theSize);
36
37 //! Release memory
38 Standard_EXPORT virtual void Free (void* theAddress);
39
40 // Declaration of CASCADE RTTI
41 DEFINE_STANDARD_RTTI(NCollection_WinHeapAllocator)
42
43private:
44 //! Copy constructor - prohibited
45 NCollection_WinHeapAllocator (const NCollection_WinHeapAllocator& );
46
47private:
48#if(defined(_WIN32) || defined(__WIN32__))
49 void* myHeapH;
50#endif
51 Standard_Boolean myToZeroMemory;
52
53};
54
55// Definition of HANDLE object using Standard_DefineHandle.hxx
56DEFINE_STANDARD_HANDLE (NCollection_WinHeapAllocator, NCollection_BaseAllocator)
57
58#endif //NCollection_WinHeapAllocator_HeaderFile