Abstract The paper presents the results of analytical and numerical studies of the capillary trapping phenomena occurring in 3-phase flow. Based on theoretical results, a numerical procedure and a software package has been developed providing an easy way to compute distribution of residual oil in a heterogeneous 1D reservoir. For a given set of relative permeabilities and capillary pressure, the saturation profiles are generated for different types of wettability of the rock and different types of boundary conditions which are relevant for reservoir and laboratory. The main characteristics influencing the process of capillary trapping are wettability type, and the 2 capillary numbers showing the relative strength of capillary forces for oil-water and oil-gas as compared to the viscous forces. It is shown that the type of boundary conditions as well as wettability will strongly influence the amount of the capillary trapped oil and gas.