wxWidgets/Win32: Added a private heap allocation feature, which directs all wxString and wxObject allocations through a Windows private Heap (should reduce fragmentation and multithreaded contention when allocating/freeing blocks)

(and fix some oddball compilation errors in spu2-x in rare circumstances)

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1987 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-10-08 19:26:57 +00:00
parent 53dd6b728a
commit 67957b13b6
10 changed files with 82 additions and 7 deletions

View File

@ -5,6 +5,7 @@
Name="wxBase28"
ProjectGUID="{48AD7E0A-25B1-4974-A1E3-03F8C438D34F}"
RootNamespace="wxBase28"
TargetFrameworkVersion="0"
>
<Platforms>
<Platform
@ -573,6 +574,10 @@
RelativePath="..\..\src\msw\dlmsw.cpp"
>
</File>
<File
RelativePath="..\..\src\msw\HeapAllocator.cpp"
>
</File>
<File
RelativePath="..\..\src\msw\main.cpp"
>
@ -693,6 +698,10 @@
RelativePath="..\..\include\wx\msw\gccpriv.h"
>
</File>
<File
RelativePath="..\..\include\wx\msw\HeapAllocator.h"
>
</File>
<File
RelativePath="..\..\include\wx\msw\libraries.h"
>

View File

@ -5,6 +5,7 @@
Name="wxConfig28"
ProjectGUID="{C34487AF-228A-4D11-8E50-27803DF76873}"
RootNamespace="wxConfig"
TargetFrameworkVersion="0"
>
<Platforms>
<Platform
@ -126,6 +127,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\include\wx\setup.h"
>
</File>
<File
RelativePath="..\..\include\wx\msw\setup.h"
>
@ -160,10 +165,6 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\include\wx\setup.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"

View File

@ -5,6 +5,7 @@
Name="wxCore28"
ProjectGUID="{0318BA30-EF48-441A-9E10-DC85EFAE39F0}"
RootNamespace="wxCore"
TargetFrameworkVersion="0"
>
<Platforms>
<Platform

View File

@ -433,6 +433,40 @@ public:
// Turn on the correct set of new and delete operators
#if wxUSE_PRIVATE_HEAP && defined(__WXMSW__)
void* operator new( size_t size, const wxChar * = NULL, int = 0 )
{
_allocateHeap_wxObject();
return _allocHeap_wxObject( size );
}
void *operator new[] ( size_t size, const wxChar * = NULL, int = 0 )
{
_allocateHeap_wxObject();
return _allocHeap_wxObject( size );
}
void operator delete( void* ptr )
{
_freeHeap_wxObject( ptr );
}
void operator delete( void* ptr, const wxChar*, int )
{
_freeHeap_wxObject( ptr );
}
void operator delete[]( void* ptr )
{
_freeHeap_wxObject( ptr );
}
void operator delete[]( void* ptr, const wxChar*, int )
{
_freeHeap_wxObject( ptr );
}
#else
#ifdef _WX_WANT_NEW_SIZET_WXCHAR_INT
void *operator new ( size_t size, const wxChar *fileName = NULL, int lineNum = 0 );
#endif
@ -459,6 +493,7 @@ public:
#ifdef _WX_WANT_ARRAY_DELETE_VOID_WXCHAR_INT
void operator delete[] (void* buf, const wxChar*, int );
#endif
#endif
// ref counted data handling methods

View File

@ -86,7 +86,7 @@
// Default is 0
//
// Recommended setting: 1 if you are not using a memory debugging tool, else 0
#define wxUSE_MEMORY_TRACING 1
#define wxUSE_MEMORY_TRACING 0
// In debug mode, cause new and delete to be redefined globally.
// If this causes problems (e.g. link errors which is a common problem
@ -109,6 +109,20 @@
// Recommended setting: 0
#define wxUSE_DEBUG_NEW_ALWAYS 0
// [PCSX2 Extension (Win32-specific)]
// Tells wxWidgets to use private heaps for wxString and wxObject. This is very
// useful for two reasons: it tends to be a good speedup, since these objects
// allocate a lot of small blocks that fragment the global heap, and it also
// bypasses the CRT, which avoids heap pollution when looking for memory leaks.
// Typically wxWidgets is leak-free so you only want your own app's blocks in
// the global CRT heap.
//
// Default is 1.
//
// Recommended Setting: 1 (wxWidgets developers my find it useful to use 0).
//
#define wxUSE_PRIVATE_HEAP 1
// wxHandleFatalExceptions() may be used to catch the program faults at run
// time and, instead of terminating the program with a usual GPF message box,
// call the user-defined wxApp::OnFatalException() function. If you set

View File

@ -174,11 +174,18 @@ inline int Stricmp(const char *psz1, const char *psz2)
#include "wx/beforestd.h"
#include <string>
#if wxUSE_PRIVATE_HEAP && defined(__WXMSW__)
# include "wx/msw/HeapAllocator.h"
#endif
#include "wx/afterstd.h"
#if wxUSE_UNICODE
#ifdef HAVE_STD_WSTRING
typedef std::wstring wxStdString;
#if wxUSE_PRIVATE_HEAP && defined(__WXMSW__)
typedef std::basic_string< wchar_t, std::char_traits< wchar_t >, wxStringAllocator<wchar_t> > wxStdString;
#else
//typedef std::wstring wxStdString;
#endif
#else
typedef std::basic_string<wxChar> wxStdString;
#endif

View File

@ -282,12 +282,16 @@ bool wxEntryStart(int& argc, wxChar **argv)
}
}
// PCSX2: Dunno why my operator new overload fails to work on this. Says it needs
// one with four parameters... ?
#if !wxUSE_PRIVATE_HEAP || !defined(__WXMSW__)
if ( !app.get() )
{
// either IMPLEMENT_APP() was not used at all or it failed -- in any
// case we still need something
app.Set(new wxDummyConsoleApp);
}
#endif
// wxApp initialization: this can be customized

View File

@ -18,6 +18,8 @@
#ifndef _SPU2X_GLOBAL_H_
#define _SPU2X_GLOBAL_H_
#define NOMINMAX
struct StereoOut16;
struct StereoOut32;
struct StereoOutFloat;

View File

@ -63,7 +63,7 @@ __forceinline void Verifyc(HRESULT hr, const char* fn)
void AssignSliderValue( HWND idcwnd, HWND hwndDisplay, int value )
{
value = min( max( value, 0 ), 512 );
value = std::min( std::max( value, 0 ), 512 );
SendMessage(idcwnd,TBM_SETPOS,TRUE,value);
wchar_t tbox[32];

View File

@ -1,8 +1,10 @@
#pragma once
#ifndef WINVER
# define WINVER 0x0501
# define _WIN32_WINNT 0x0501
#endif
#include <windows.h>
#include <mmsystem.h>