"Sampo's Delight" - add "do not show this window again" to memory warning; check physical RAM on linux and only warn if limit is less than 75% of total RAM; do nothing on OSX since there is no mlockall there
git-svn-id: svn://localhost/ardour2/trunk@1534 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
9c1e0194f7
commit
161b8b92a2
|
@ -437,27 +437,71 @@ ARDOUR_UI::save_ardour_state ()
|
|||
void
|
||||
ARDOUR_UI::startup ()
|
||||
{
|
||||
if (engine->is_realtime()) {
|
||||
check_memory_locking();
|
||||
}
|
||||
|
||||
void
|
||||
ARDOUR_UI::no_memory_warning ()
|
||||
{
|
||||
XMLNode node (X_("no-memory-warning"));
|
||||
Config->add_instant_xml (node, get_user_ardour_path());
|
||||
}
|
||||
|
||||
void
|
||||
ARDOUR_UI::check_memory_locking ()
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
/* OS X doesn't support mlockall(2), and so testing for memory locking capability there is pointless */
|
||||
return;
|
||||
#endif
|
||||
|
||||
XMLNode* memory_warning_node = Config->instant_xml (X_("no-memory-warning"), get_user_ardour_path());
|
||||
|
||||
if (engine->is_realtime() && memory_warning_node == 0) {
|
||||
|
||||
struct rlimit limits;
|
||||
|
||||
int64_t ram;
|
||||
long pages, page_size;
|
||||
|
||||
if ((page_size = sysconf (_SC_PAGESIZE)) < 0 ||(pages = sysconf (_SC_PHYS_PAGES)) < 0) {
|
||||
ram = 0;
|
||||
} else {
|
||||
ram = (int64_t) pages * (int64_t) page_size;
|
||||
}
|
||||
|
||||
if (getrlimit (RLIMIT_MEMLOCK, &limits)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (limits.rlim_cur != RLIM_INFINITY) {
|
||||
MessageDialog msg (_("WARNING: Your system has a limit for maximum amount of locked memory. "
|
||||
"This might cause Ardour to run out of memory before your system "
|
||||
"runs out of memory. \n\n"
|
||||
"You can view the memory limit with 'ulimit -l', "
|
||||
"and it is normally controlled by /etc/security/limits.conf"));
|
||||
|
||||
if (ram == 0 || ((double) limits.rlim_cur / ram) < 0.75) {
|
||||
|
||||
editor->ensure_float (msg);
|
||||
msg.run ();
|
||||
|
||||
MessageDialog msg (_("WARNING: Your system has a limit for maximum amount of locked memory. "
|
||||
"This might cause Ardour to run out of memory before your system "
|
||||
"runs out of memory. \n\n"
|
||||
"You can view the memory limit with 'ulimit -l', "
|
||||
"and it is normally controlled by /etc/security/limits.conf"));
|
||||
|
||||
VBox* vbox = msg.get_vbox();
|
||||
HBox hbox;
|
||||
CheckButton cb (_("Do not show this window again"));
|
||||
|
||||
cb.signal_toggled().connect (mem_fun (*this, &ARDOUR_UI::no_memory_warning));
|
||||
|
||||
hbox.pack_start (cb, true, false);
|
||||
vbox->pack_start (hbox);
|
||||
hbox.show_all ();
|
||||
|
||||
editor->ensure_float (msg);
|
||||
msg.run ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ARDOUR_UI::finish()
|
||||
{
|
||||
|
|
|
@ -697,6 +697,9 @@ class ARDOUR_UI : public Gtkmm2ext::UI
|
|||
|
||||
bool can_save_keybindings;
|
||||
bool first_idle ();
|
||||
|
||||
void no_memory_warning ();
|
||||
void check_memory_locking ();
|
||||
};
|
||||
|
||||
#endif /* __ardour_gui_h__ */
|
||||
|
|
Loading…
Reference in New Issue
Block a user