本文整理汇总了C++中MemArena::GrabLowMemSpace方法的典型用法代码示例。如果您正苦于以下问题:C++ MemArena::GrabLowMemSpace方法的具体用法?C++ MemArena::GrabLowMemSpace怎么用?C++ MemArena::GrabLowMemSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemArena
的用法示例。
在下文中一共展示了MemArena::GrabLowMemSpace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MemoryMap_Setup
bool MemoryMap_Setup(u32 flags) {
#if PPSSPP_PLATFORM(UWP)
// We reserve the memory, then simply commit in TryBase.
base = (u8*)VirtualAllocFromApp(0, 0x10000000, MEM_RESERVE, PAGE_READWRITE);
#else
// Figure out how much memory we need to allocate in total.
size_t total_mem = 0;
for (int i = 0; i < num_views; i++) {
if (views[i].size == 0)
continue;
SKIP(flags, views[i].flags);
if (!CanIgnoreView(views[i]))
total_mem += g_arena.roundup(views[i].size);
}
// Grab some pagefile backed memory out of the void ...
g_arena.GrabLowMemSpace(total_mem);
#endif
#if !PPSSPP_PLATFORM(ANDROID)
if (g_arena.NeedsProbing()) {
int base_attempts = 0;
#if defined(_WIN32) && PPSSPP_ARCH(32BIT)
// Try a whole range of possible bases. Return once we got a valid one.
uintptr_t max_base_addr = 0x7FFF0000 - 0x10000000;
uintptr_t min_base_addr = 0x01000000;
uintptr_t stride = 0x400000;
#else
// iOS
uintptr_t max_base_addr = 0x1FFFF0000ULL - 0x80000000ULL;
uintptr_t min_base_addr = 0x100000000ULL;
uintptr_t stride = 0x800000;
#endif
for (uintptr_t base_addr = min_base_addr; base_addr < max_base_addr; base_addr += stride) {
base_attempts++;
base = (u8 *)base_addr;
if (Memory_TryBase(flags)) {
INFO_LOG(MEMMAP, "Found valid memory base at %p after %i tries.", base, base_attempts);
return true;
}
}
ERROR_LOG(MEMMAP, "MemoryMap_Setup: Failed finding a memory base.");
PanicAlert("MemoryMap_Setup: Failed finding a memory base.");
return false;
}
else
#endif
{
#if !PPSSPP_PLATFORM(UWP)
base = g_arena.Find4GBBase();
#endif
}
// Should return true...
return Memory_TryBase(flags);
}
示例2: MemoryMap_Setup
void MemoryMap_Setup(u32 flags)
{
// Find a base to reserve 256MB
#if defined(_XBOX)
base = (u8*)VirtualAlloc(0, 0x10000000, MEM_RESERVE|MEM_LARGE_PAGES, PAGE_READWRITE);
#elif defined(__SYMBIAN32__)
memmap = new RChunk();
memmap->CreateDisconnectedLocal(0 , 0, 0x10000000);
base = memmap->Base();
#else
size_t total_mem = 0;
for (int i = 0; i < num_views; i++)
{
if (views[i].size == 0)
continue;
SKIP(flags, views[i].flags);
if (!CanIgnoreView(views[i]))
total_mem += g_arena.roundup(views[i].size);
}
// Grab some pagefile backed memory out of the void ...
g_arena.GrabLowMemSpace(total_mem);
// 32-bit Windows retrieves base a different way
#if defined(_M_X64) || !defined(_WIN32)
// This really shouldn't fail - in 64-bit, there will always be enough address space.
// Linux32 is fine with the x64 method, although limited to 32-bit with no automirrors.
base = MemArena::Find4GBBase();
#endif
#endif
// Now, create views in high memory where there's plenty of space.
#if defined(_WIN32) && !defined(_M_X64) && !defined(_XBOX)
// Try a whole range of possible bases. Return once we got a valid one.
int base_attempts = 0;
u32 max_base_addr = 0x7FFF0000 - 0x10000000;
for (u32 base_addr = 0x01000000; base_addr < max_base_addr; base_addr += 0x400000)
{
base_attempts++;
base = (u8 *)base_addr;
if (Memory_TryBase(flags))
{
INFO_LOG(MEMMAP, "Found valid memory base at %p after %i tries.", base, base_attempts);
base_attempts = 0;
break;
}
}
if (base_attempts)
PanicAlert("No possible memory base pointer found!");
#else
// Try base we retrieved earlier
if (!Memory_TryBase(flags))
{
ERROR_LOG(MEMMAP, "MemoryMap_Setup: Failed finding a memory base.");
PanicAlert("MemoryMap_Setup: Failed finding a memory base.");
}
#endif
return;
}