Project

General

Profile

Actions

Emulator Issues #5625

closed

On Linux, 784 MB free memory is required to start emulation

Added by plbl4ster over 11 years ago.

Status:
Fixed
Priority:
Normal
Assignee:
-
% Done:

0%

Operating system:
N/A
Issue type:
Bug
Milestone:
Regression:
No
Relates to usability:
No
Relates to performance:
No
Easy:
No
Relates to maintainability:
No
Regression start:
Fixed in:

Description

When running on Linux, Dolphin requires 784 MB RAM+swap available to start emulation. (No such requirement when running on Windows.) To fix it, in Source/Core/Common/Src/MemArena.cpp in Find4GBBase I changed from:

void* base = mmap(0, 0x31000000, PROT_READ | PROT_WRITE,
MAP_ANON | MAP_SHARED, -1, 0);

to:

void* base = mmap(0, 0x31000000, PROT_NONE,
MAP_ANON | MAP_PRIVATE, -1, 0);

Some explanation. When mmap is used with PROT_NONE and MAP_PRIVATE it does not count as overcommit (source: http://www.kernel.org/doc/Documentation/vm/overcommit-accounting ). This is how Wine translates the Windows call to VirtualAlloc in Dolphin (I've checked using strace). See also this post on PCSX2 forum: http://forums.pcsx2.net/Thread-blog-VirtualAlloc-on-Linux

As the memory is unmapped immediately, I understand that mmap is only called for its return value and not any side effects? On my system it always returns an address from the same range, before and after making this modification. Anyway, I don't have enough knowledge on this topic to say with certainty that this change won't break anything, I can only say that it works for me.

Actions #1

Updated by willianholtz1 over 11 years ago

Right! the same happening here!

Actions #2

Updated by Sonicadvance1 over 11 years ago

  • Status changed from New to Accepted

Yea, this is something I had been meaning to look at for a while. I might commit this later tonight.

Actions #3

Updated by Sonicadvance1 over 11 years ago

hm, Upon testing this doesn't actually work for me. I'll have to look in to it more.

Actions #4

Updated by plbl4ster over 11 years ago

Do you mean that it still can't allocate memory, or that it succeeds but something else is broken?

I'm attaching a simple test program. On my system:

$ gcc -o mmaptest mmaptest.c
$ ./mmaptest
using the "old" behavior
128 MB: ok
256 MB: ok
512 MB: ok
784 MB: error 12: Cannot allocate memory
1280 MB: error 12: Cannot allocate memory
2048 MB: error 12: Cannot allocate memory
using the "new" behavior
128 MB: ok
256 MB: ok
512 MB: ok
784 MB: ok
1280 MB: ok
2048 MB: ok

If you want you can try it to see if you get similar results.

Actions #5

Updated by Sonicadvance1 over 11 years ago

Oh yea, it does work. I was just being a derp and changed the first mmap I seen to MemArena.

Actions #6

Updated by Sonicadvance1 over 11 years ago

  • Status changed from Accepted to Fixed

This issue was closed by revision b4ae200d0dde.

Actions

Also available in: Atom PDF