Calculate threshold before putting data in deserialization to avoid memory issue bug 34265, reported by Marcos Cesar de Oliveira