Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

111
Visualizações
Memory leaks in Java and spring using JaxWsProxyFactoryBean

I have an application in Java that uses CXF to make calls to a web service. The code for the initiator looks like

import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.tempuri.IAPIService;

import javax.inject.Inject;

/**
 * Created by flavius on 23/09/14.
 */
@Component()
public class VsJaxWsProxyFactory {

  @Inject
  private Environment env;

  private JaxWsProxyFactoryBean factoryBean = null;

  public Object create() {
    if (factoryBean == null) {

      factoryBean = new JaxWsProxyFactoryBean();
      factoryBean.setServiceClass(IAPIService.class);
      factoryBean.setAddress(env.getProperty("api.wsdl"));
    }
    return factoryBean.create();
  }
}

The application runs fine, but after a while the box starts to consume too much memory and the application starts running slow. When we tried to do a memory analysis we found the following Memory Analysis

It seems that the CXF is somehow creating a new Service configuration object on each call, and is not being released. I can't find much information on org.apache.cxf.jaxws.support.JaxWsServiceConfiguration class and not sure if this is a configuration issue or some internal bug in some library.

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Already answered here: Apache CXF not releasing clients

Basically .create() method on the same JaxWsProxyFactoryBean instance should be called only once, otherwise you get a memory leak:

return factoryBean.create();

factoryBean.create() returns the cxf JAX-WS client proxy, which you can reuse for repeated calls. Created client is also thread safe if you don't use any special features mentioned here http://cxf.apache.org/faq.html#FAQ-AreJAX-WSclientproxiesthreadsafe?

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda