There are 3 ways to defend against the damage ice dams can cause: insulation, ventilation and shingle underlayment. All 3 work together. Insulation keeps the heat from escaping your home. Ventilation removes the heat and helps keep the roof deck cool to help prevent snow from melting on the roof. Finally, waterproofing underlayment must be laid before shingles are applied as a critical last line of defense against leaks, preventing backed up water from getting into your home wherever it is applied.
To prevent an ice dam, don’t heat the roof, keep it cold. The underside of the roof deck should not exceed 30° F. The best way to maintain low temperatures is by ensuring that there is adequate insulation. The attic must also be ventilated, so that cold air is introduced into it and heated air escapes rapidly, that way, the snow on the roof eventually dissipates without making large amounts of melted water. Another solution would be to have large amounts of snow removed from your roof before it has a chance to start the melting / freezing process.