Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

112
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda