Epigenetic inheritance of gene-silencing is maintained by a self-tuning mechanism based on resource competition