An image forming apparatus comprising: image forming means including a containing unit that contains toner, and configured to form an image based on image data by using the toner contained in the containing unit; replenishment means (67, 69) configured to replenish the containing unit with toner; first determination means configured to determine, based on the image data, a consumption amount of the toner to be consumed in the containing unit; detection means provided to the containing unit, configured to detect an amount of the toner contained in the containing unit; first calculating means configured to calculate a difference between the amount of the toner detected by the detection means and a target amount; second calculating means configured to accumulate the difference calculated by the first calculation unit to calculate a cumulative value of the difference; second determination means (1105, 1106) configured to determine a determination value used for determining whether the replenishment means (67, 69) replenishes the containing unit with toner, based on the consumption amount determined by the first determination means, the difference calculated by the first calculating means, and the cumulative value calculated by the second calculating means; and a controller configured to control the replenishment means (67, 69), based on the determination value determined by the second determination means (1105, 1106), wherein: the first calculating means performs difference calculation in a predetermined period, the second calculating means does not perform accumulation calculation in the predetermined period, and the predetermined period corresponds to a period in which the determination value determined by the second determination means (1105, 1106) is smaller than a threshold. image forming means including a containing unit that contains toner, and configured to form an image based on image data by using the toner contained in the containing unit; replenishment means (67, 69) configured to replenish the containing unit with toner; first determination means configured to determine, based on the image data, a consumption amount of the toner to be consumed in the containing unit; detection means provided to the containing unit, configured to detect an amount of the toner contained in the containing unit; first calculating means configured to calculate a difference between the amount of the toner detected by the detection means and a target amount; second calculating means configured to accumulate the difference calculated by the first calculation unit to calculate a cumulative value of the difference; second determination means (1105, 1106) configured to determine a determination value used for determining whether the replenishment means (67, 69) replenishes the containing unit with toner, based on the consumption amount determined by the first determination means, the difference calculated by the first calculating means, and the cumulative value calculated by the second calculating means; and a controller configured to control the replenishment means (67, 69), based on the determination value determined by the second determination means (1105, 1106), wherein: the first calculating means performs difference calculation in a predetermined period, the second calculating means does not perform accumulation calculation in the predetermined period, and the predetermined period corresponds to a period in which the determination value determined by the second determination means (1105, 1106) is smaller than a threshold. the first calculating means performs difference calculation in a predetermined period, the second calculating means does not perform accumulation calculation in the predetermined period, and the predetermined period corresponds to a period in which the determination value determined by the second determination means (1105, 1106) is smaller than a threshold.