publicissapient-france/selma

OutOfMemoryError on mappers generation

NicoHvt opened this issue · 5 comments

Hello,
I got an important problem about Mapper generation. My project now contains a lot of mapper interfaces (

Error:java: java.lang.OutOfMemoryError: WrappedJavaFileObject[org.jetbrains.jps.javac.OutputFileObject[file:///Users/classes/generated/com/appli/converter/mapper/CampaignLightMapperSelmaGeneratedClass.java]]@pos192752: WrappedJavaFileObject[org.jetbrains.jps.javac.OutputFileObject[file:///Users/classes/generated/com/appli/converter/mapper/CampaignLightMapperSelmaGeneratedClass.java]]@pos192760: WrappedJavaFileObject[org.jetbrains.jps.javac.OutputFileObject[file:///Users/classes/generated/com/appli/converter/mapper/CampaignLightMapperSelmaGeneratedClass.java]]@pos192783: WrappedJavaFileObject[org.jetbrains.jps.javac.OutputFileObject[file:///Users/classes/generated/com/appli/converter/mapper/CampaignLightMapperSelmaGeneratedClass.java]]@pos197048: WrappedJavaFileObject[org.jetbrains.jps.javac.OutputFileObject[file:///Users/classes/generated/com/appli/converter/mapper/CampaignLightMapperSelmaGeneratedClass.java]]@pos197051: WrappedJavaFileObject[org.jetbrains.jps.javac.OutputFileObject[file:///Users/classes/generated/com/appli/converter/mapper/CampaignLightMapperSelmaGeneratedClass.java]]@pos197075: WrappedJavaFileObject[org.jetbrains.jps.javac.OutputFileObject[file:///Users/classes/generated/com/appli/converter/mapper/CampaignLightMapperSelmaGeneratedClass.java]]@pos197072: GC overhead limit exceeded
Here comes an example of mapper configuration:

/**

  • Mapper for campaign entity without lazy fields.
    */
    @Mapper(ignoreMissingProperties = true,
    withIgnoreNullValue = true,
    withIoC = IoC.SPRING,
    withCyclicMapping = true,
    withCustom = {MoneyToMoneyCustomMapper.class, JsonToJsonCustomMapper.class}
    )
    public interface CampaignLightMapper extends CampaignMapper {

/**

  • Convert Campaign to CampaignDto.
  • @param in Campaign to convert.
  • @return converted CampaignDto.
    */
    @maps(withIgnoreFields = {
    "wallet",
    "distributedByUser",
    "reason",
    "recreditedType",
    "distributionCampaignLinks"},
    withCustom = DepositLightMapper.class
    )
    CampaignDto asCampaignDto(Campaign in);
    }

Even increasing the VM memory the error occurs but on a different mapper class. So I don't think it comes from a specific mapper.

Could you help me please?

I tried different configuration but problems occurs on different mappers. Fact is that the mapper generation uses too much memory and GC keep falling with the same issue after a long compilation time.

Help

@NicoHvt would you mind sharing how many mapper interfaces you had?

Hie @lucjross,
I uses about 200 mappers. At the beginning are less than 30 entities but I defined several mapping versions for each to make more or less heavy the mapping results.

Hi @NicoHvt,

what is the size of the generated file : file:///Users/classes/generated/com/appli/converter/mapper/CampaignLightMapperSelmaGeneratedClass.java ?

If this file is really huge, there is either an infinite loop somewhere allocating way to much MappingSourceNode. Analyzing the heapdump on out of memory would be helpfull.

Can you provide a sample code or integration test reproducing the OOM ?

Mapping methods are built using a MappingSourceNode tree, that can not be freed by GC until the complete method add been generated.

Hi,

Sorry for the late response. I Found how to make it lighter with some mapping customization and finally compilation works in relatively short time.
I think there was no solution but increasing the memory allocated allows the process to ends not crashing.

Thank you