Fix memory leak in shadow plugin, sync after each swap buffer.