custom serialization problem (marshal_dump, marshal_load)

The serialization works correctly when the number of objects YYY is
small, but when it got more than 5000, the serialization doesn't work.
(the serializaed file has more and less 1 meg)

Asking smart questions, lesson 1. Never say "it doesn't work". Do say
exactly what happens and how that differs from what you expected.