An image forming apparatus, comprising: a print queue that stores print jobs including a print job number, a print job ID, a print job page, and a print job state, which are included in print jobs, wherein the print job number is from "1" to a maximum number of storable pages in the print queue; a job writing unit that writes the print jobs into the print queue; a print execution unit that executes print on a recording medium based on a page being sequentially read from the print queue, wherein, if a second print job other than a first print job of currently executed printing is cancelled from among the print jobs written into the print queue, the print execution unit suspends execution of the print of the first job; a connected-state detection unit that detects a connected state of extension devices affecting a length of a conveyance path of the recording medium; and a maximum-number-of-storable-pages changing unit that changes the maximum number of storable pages, a corresponding-relationship storage unit that stores a corresponding relationship of the connected state and the maximum number of storable pages; the maximum-number-of-storable-pages changing unit changes the maximum number of storable pages, based on the connected state of the extension devices detected by the connected-state detection unit, and on the corresponding relationship stored in the corresponding-relationship storage unit; the extension devices includes a medium feed unit and a post processing unit; the maximum number of storable pages in a case in which none of the medium feed unit and the post processing unit is connected to the image forming apparatus is smaller than the maximum number of storable pages in a case in which only one of the medium feed unit and the post processing unit is connected to the image forming apparatus; and the maximum number of storable pages in the case in which only one of the medium feed unit and the post processing unit is connected to the image forming apparatus is smaller than the maximum number of storable pages in a case in which both of the medium feed unit and the post processing unit are connected to the image forming apparatus. a print queue that stores print jobs including a print job number, a print job ID, a print job page, and a print job state, which are included in print jobs, wherein the print job number is from "1" to a maximum number of storable pages in the print queue; a job writing unit that writes the print jobs into the print queue; a print execution unit that executes print on a recording medium based on a page being sequentially read from the print queue, wherein, if a second print job other than a first print job of currently executed printing is cancelled from among the print jobs written into the print queue, the print execution unit suspends execution of the print of the first job; a connected-state detection unit that detects a connected state of extension devices affecting a length of a conveyance path of the recording medium; and a maximum-number-of-storable-pages changing unit that changes the maximum number of storable pages, a corresponding-relationship storage unit that stores a corresponding relationship of the connected state and the maximum number of storable pages;