Tendon locking

Tendon locking is used by many animal species which sleep in trees or caves. It lets them sleep without falling off. The system has evolved separately in a number of vertebrates, so it is an example of parallel evolution.
Bird feet.
The leg arrangement of passerine birds has a special adaption for perching: a "tendon-locking mechanism". A tendon in the rear of the leg is automatically pulled and tightened when the leg bends. This makes the foot curl stiffly round when the bird lands on a branch. The tendon is locked in place by another tendon. So passerines sleep while perching without falling off.
Small mammals.
Small animals which sleep in trees or caves usually hang on with their feet: they have a tendon locking device which keeps them hanging on even during sleep. It works by one tendon running down the leg shifting position slightly so it grips the tendon which closes the toes. Bats independently evolved a similar arrangement. Once the tendons are locked, the muscles in their legs and feet can relax. Even dead bats stay hanging. These various examples have evolved independently of each other: this is known from the fine details of the mechanism. One plus of a locking mechanism is that it allows attachment to slender branches on which predators might be unable to walk.
Linking behaviours.
There are various group behaviours which supplement the effect of
tendon locking. The most obvious is complete silence. Starlings migrate in large groups, and they can go from making a huge noise to complete silence after landing on an overnight roost.