Chronicle-Bytes
                                
                                 Chronicle-Bytes copied to clipboard
                                
                                    Chronicle-Bytes copied to clipboard
                            
                            
                            
                        Support for garbage-free collection field deserialization
Hi!
I'm interested in garbage-free implementation of BytesMarshallable.readMarshallable(BytesIn) for marshallable objects with collection fields.
Currently, I have a class (e.g. MyMarshallable extends BytesInBinaryMarshallable) with the List<MyOtherMarshallable> field and as far as I can see the BytesMarshaller.CollectionFieldAccess will be used for this field. During read routine, CollectionFieldAccess initially clears the underlying collection and then delegates to the BytesIn#readObject for a new element provision, which eventually will allocate a new instance for each unmarshalled element.
I understand that it is not a trivial task to implement it garbage-free in a generic way since you have to take into account a bunch of details such as inheritance, reference leaking, collection resizing, etc. Also, I perfectly understand that I can simply override the readMarshallable method for my specific object type and provide a hand-crafted desererializarion logic. But, it seems tedious in cases where you have the only one collection field to care and a lot of plain fields that reuse objects out-of-the-box.
For my specific case I'm 100% sure that there will be strictly one underlying type (no inheritance), I control object lifecycle and so on, so it will be handy to at least have a possibility to override FieldAccess logic for some specific fields to employ my own object pooling to it.
Please tell if you have plans to introduce any of this:
- The way to somehow provide a custom allocator to replace an auto-resolved constructor from ObjectUtils.newInstance().
- The facility (field annotation or smth) to override FieldAccesslogic for a concrete field with some custom implementation.
Thanks!
@RobAustin please assign as appropriate
Are we going to do this?
Sorry for the delay in responding, We can provide consultancy to help you with this, if it is still required please contact [email protected], but In summary, we have automated field pooling of one object per type but beyond that, we will have to look at your individual requirements.