A ventilator apparatus, method, system, and computer program for determining leakage in a flow circuit providing pressurized gas to a patient having breathing disorder. The present invention determines the leakage by calculating a ratio between a measured flow of gas and a determined flow of gas related to a standard leakage. The determined standard leak flow may be calculated from a formula derived from Bernoullis theorem. The invention may further be arranged to use a volume difference between inspiration and expiration phases in the compensation process.