--- deliantra/server/ext/map-scheduler.ext 2007/01/22 03:44:41 1.24 +++ deliantra/server/ext/map-scheduler.ext 2007/01/23 01:05:17 1.25 @@ -8,6 +8,7 @@ our $SWAP_TIMEOUT = 35; # number of seconds after which maps inactive get swapped out our $SCHEDULE_INTERVAL = 2; # time the map scheduler sleeps between runs our $SAVE_TIMEOUT = 20; # save maps every n seconds +our $MAX_ACTIVES = $cf::CFG{max_actives} || 200000; # swap aggressively when > this many objects are active cf::async_ext { $Coro::current->prio (Coro::PRIO_MIN); @@ -55,12 +56,13 @@ if ($map->should_reset) { $map->reset; } elsif ($map->in_memory == cf::MAP_IN_MEMORY) { - if ($map->last_access + $SWAP_TIMEOUT <= $cf::RUNTIME && !$map->players) { - $cf::WAIT_FOR_TICK_ONE->wait; + if ((cf::object::actives_size > $MAX_ACTIVES || $map->last_access + $SWAP_TIMEOUT <= $cf::RUNTIME) + && !$map->players) { $map->swap_out; - } elsif ($map->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { $cf::WAIT_FOR_TICK_ONE->wait; + } elsif ($map->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { $map->save; + $cf::WAIT_FOR_TICK_ONE->wait; } } };