Avoiding Leaks on Undeploy

When the servlet context is destoryed, must I manually stop all my running threads (especially the ones that don't run forever) or does Tomcat handles stopping threads by itself? Or can I just set whatever threads I use to "daemon" and then not have to worry about it? Please help.

Well if you think your application gives you certain amount of control to terminate those using certain wrappers.
The best solution for you to implement a ServletContextListener and register it in web.xml
[http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/ServletContextListener.html]
and write your respective code in contextDestroyed(ServletContextEvent sce) such that we can ensure that there would not any leaks in the stated aspects on Undeploy.
In the otherwise case it certainly depends on the way the Stated ServletContainer handles it.

Similar Messages

  • Avoid undeploy/deploy when installing Updates?

    Hello Community,
    when our BO environment was first set up (years ago) the option "Install Tomcat application server and automatically deploy web applications and services to it" was checked. So the bundled Tomcat was installed and everything will be automatically deployed.
    This means with every update web applications get undeployed and then deployed. When installing several Service Packs and Patches in a row this takes so much time..
    Is there a way to stop auto undeploy/deply and do it manually after all updates finished? I am looking for a configfile like wdeploy.conf or something else.
    Regards,
    Michael

    Hi Sid,
    for example you have to install several updates on your production system in a row:
    - 4.1 SP4 Platform update
    - 4.1 SP4 Explorer update
    - DS 1.3 SP1 update
    - 4.1 SP4 Patch 1 Platform update
    - 4.1 SP4 Patch 1 Explorer update
    with every update/patch the installer undeploys the old web apps and deploys the new ones, but as we install all updates/patches in a row this effort is only needed one time!
    This is also mentioned here: BI Suite Performance - Business Intelligence (BusinessObjects) - SCN Wiki
    Install the BI Platform without automatically deploying the web
    applications. This will then avoid the step 'undeploy web applications'
    which is taken by 'patch' updates during a software update. This step
    can be taken manually or via script after the update process. This can
    save considerable time.
    So this is why i am asking if it is possible to change this behaviour within a configuration file or something? Because when we first installed our platform we set it to automatically deploy.
    Regards,
    Michael

  • Sound leak when using unsigned

    I've generated a simple test case which should make this pretty straightforward. I'm using Linux Ubuntu 11.04 with pulseaudio, if it makes any difference.
    Basically, I generate a very simple tonal sound for the musical note A3 using Java's java.sound.sampled APIs, and Clip to open and play it.
    That's all well and good, but to avoid leaking sound resources, I have to listen to the Clip (or Line) for a STOP event, and then close it. That's fine too. If I play two sounds at the same time and do this, it works fine, too...
    unless the sound encoding is unsigned. For some reason, switching it from signed to unsigned (and translating the tonal wave appropriately) makes me only able to close one of the Lines, and the other one goes rogue.
    Here's my code:
    http://pastebin.com/1mxBJ61t
    or
    import java.util.Timer;
    import java.util.TimerTask;
    import javax.sound.sampled.AudioFormat;
    import javax.sound.sampled.AudioSystem;
    import javax.sound.sampled.Clip;
    import javax.sound.sampled.DataLine;
    import javax.sound.sampled.LineEvent;
    import javax.sound.sampled.LineListener;
    import javax.sound.sampled.LineEvent.Type;
    public class Test
         public static void main(String[] args)
              int volume = 64; //0-256
              double seconds = 2.0;
              double tone = 220.0; //Musical note A3 = 220.0
              final int sps = 80000; //sample rate (samples per second)
              final boolean signed = false;
              final byte[] toneData = makeTone(sps,tone,(int) (sps * seconds),volume,signed);
              //play the first tone
              try
                   play(toneData,sps,signed);
              catch (Exception e)
                   e.printStackTrace();
              //halfway through, play the second tone
              new Timer().schedule(new TimerTask()
                        @Override
                        public void run()
                             try
                                  play(toneData,sps,signed);
                             catch (Exception e)
                                  e.printStackTrace();
                   },(long) (seconds * 500));
              //since the program doesn't know to terminate itself, we'll give it an explicit terminate
              new Timer().schedule(new TimerTask()
                        @Override
                        public void run()
                             System.out.println("Terminating");
                             System.exit(0);
                   },(long) (seconds * 2000));
         //generates a simple tonal wave
         public static byte[] makeTone(int sps, double freq, int duration, int volume, boolean signed)
              byte[] r = new byte[duration];
              for (int x = 0; x < duration; x++)
                   double wave = Math.sin((double) x / (sps / freq) * 2 * Math.PI);
                   //taper off the end so it doesn't cut prematurely and 'blip'
                   double taper = duration - x < 100 ? (duration - x) / 100. : 1;
                   byte b = (byte) ((volume * wave * taper) + (signed ? 0 : 128));
                   r[x] = b;
              return r;
         public static void play(byte[] data, int sps, boolean signed) throws Exception
              AudioFormat afmt = new AudioFormat(sps,8,1,signed,false);
              DataLine.Info info = new DataLine.Info(Clip.class,afmt);
              Clip c = (Clip) AudioSystem.getLine(info);
              c.open(afmt,data,0,data.length);
              c.start();
              //listen for the clip to stop, and then close it
              c.addLineListener(new LineListener()
                        @Override
                        public void update(LineEvent event)
                             System.out.println("Sound event: " + event.getType());
                             if (event.getType() == Type.STOP) event.getLine().close();
         }A few modifications you can make to see what I'm talking about:
    Line 21, change signed to true, and everything works great.
    Line 92, assuming signed is false, comment out this line, where I close the stream, and re-run. You will observe 2 Stop events. Enable it again and you will observe only 1 Stop event.
    Am I doing something wrong, or is Java's sound system just that deplorable?
    Thanks in advance,
    -IsmAvatar

    Thanks for replying again.
    sabre150 wrote:
    IsmAvatar wrote:
    I dropped it down to 8000, but it still does the same thing for me. II didn't say it would - just that 80,000 seemed a very high sample rate. Unless you are playing sound to bats using hardware much better than I am then anything higher than a sample rate of 44 KHz is a waste of time. At my age the highest frequency I can hear is about 8 KHz so any sample rate much above 16 KHz is too high.
    Makes sense.
    have noticed varying behaviors.
    I'm fairly new to this sound stuff, and at this point I'm just trying to get it to work. Get what to work? You have not really described, or a least I have not understood, exactly what you are trying to do. You have a clip of sound you are trying to play more than once but you are trying to "avoid leaking sound resources". Can you explain what you mean by this and why you think it necessary; a reference to some Java sound documentation would maybe help us understand.
    Well, here's the sound documentation that I'm basing my code off of: http://download.oracle.com/javase/1.5.0/docs/guide/sound/programmer_guide/chapter4.html (and chapter 3)
    Basically, my program has a play button that will play a sound that the user has loaded in (complex encodings or formats are not a concern currently). I need to be able to figure out how to handle the user clicking on the button multiple times. I would at least expect an average system to be able to play the sound twice concurrently (overlapping). Maybe I just have the wrong concept when I talk about "sound resources", but it seems like I run into problems down the road, like on my computer, after I've played the sound 30 times, it starts erroring, or if I try to play the sound twice, and then once more after they're done, it causes the application to hang. To me, this seems like it's looking for available lines, and just plum running out, or choosing a line it thinks is available, and hitting a wall. Idunno.
    I have a .wav file that uses PCI Unsigned 8000 Hz that was exhibiting this problem. I don't think the '.wav' file was not exhibiting the problem I think your code is/was .
    Fair enough. It's easier to fix the code then to expect to have certain types of wavs.
    Ultimately it leads to the application hanging entirely,
    I would be interested in seeing an SSCCE ( http://pscode.org/sscce.html ) that exhibits this since I have never met it.
    I think it would be wise to deal with one problem at a time for now. The program that exhibits it is large and would be time-consuming to simplify. I figure the problems are interrelated, so if we can fix the current problem, the apparent freezing issue should resolve itself as well. If not, then I can make an SSCCE for that.
    and I have to forcibly quit the JVM. Being able to close all sounds completely curtails that "feature", but it's apparently not an option for unsigned encodings.Since the difference between the two is just a toggle of one bit I don't really believe that this is a signed/unsigned problem. I believe there is something more fundamental to explain the problem. I expected as much. It's always nice to be able to fix one's own code/thinking than to hit a roadblock with the limitations of an API.
    >>
    Plus, your exception doesn't sound that desirable either.I didn't say it was desirable - I was just saying what I observed. My exception seems logical since the line I was trying to open was already open so a LineUnavailableException makes sense.I suppose so, yes. And I'm guessing your system is more than capable of playing two lines concurrently, if done correctly.
    I suppose the problem that you're seeing (and probably mine, too) is that it's trying to recycle the Line (just a guess - I could be completely off). For whatever reason, mine lets me play the recycled line twice, but yours doesn't. Both ways cause issues.
    I suppose this tells me that if I want to play another sound concurrently, I need another line, not a recycled one. Does that seem about right? If so, how might I go about doing that?
    If not, perhaps I'm a little thick and need some hints.
    In short, the problem is I would like to be able to play two sounds concurrently (seems like a reasonable enough request), but either I can't using my current code code (as you've seen), or it causes other issues (my side). So I'd like to know how to fix the code to enable this.
    Greatly appreciated.
    -IsmAvatar

  • Memory Leak: Do I need to explicitly free memory reference for collection?

    Hi,
    My web application uses JRockit JDK 1.4.2, Java Servlet, JSP &Struts. It is a clustered environment using WL 8.1 sp 4. I am investigating whether there are any memory leaks in the application & what are best practices to avoid leaks.
    A specific scenario is as follows:
    For an incoming request, the struts action class creates object �O� (of class A) and set �O� as a request attribute. This request attribute is used to display values on the JSP.
    Now, class A has a heavily nested structure: Class A has object of class B, where B has a HashSet of objects of type C and where C has an object of type D and E.
    Though I set this object �O� in request scope, do I need to explicitly nullify any of the references within object �O�? Can �not doing this� result in a memory leak?
    Thanks in advance,
    sjaiprakash

    jEnv->ReleaseStringUTFChars((jstring) jStr, str);free(str); //Is this line valid or outright wrong?Outright wrong.
    Another question is if ReleaseStringUTFChars actually frees str then will it set str to NULL?No, that's impossible by the semantics of C and C++.
    I guess not as we are not sending this pointer by reference.Exactly, so what you described is impossible. No need to ask really.
    My last question is if str is NULL then calling ReleaseStringUTFChars over it can cause any problem?How could it be null? If it comes from GetStringUTFChars that's impossible, and if it doesn't you don't have any business calling ReleaseStringUTFChars() on it, whatever its value.

  • How do I open a new window in Adobe Acrobat using the plugin sdk

    I would like to create a new menu item that when clicked it will open a new window (e.g. winform). What I'd like to do is pull data from a server and interact with the user in that window.  Basically show the user a list of PDF files to pull from the server.  Once the user is done selecting which file to pull to have the file pulled from the server into the local drive and have it opened in Adobe Acrobat.  The problem I'm having is that I don't know how to invoke a winform or something like it to place my lists of files and UI controls. I've looked at the samples in the SDK and don't see anything that deals with this particular issue.  I'm a newbie so I'm sure I'm missing something here.  I tried creating a new WinForm in a sample example and ran into errors and the form is not functioning.  Any help is much appreciated.

    Thank you Dan_Korn,
    This suggestion is very helpful.  I like the idea of creating the new functionality in the language/environment of my choice and simply call it from the plugin.  The only issue I have is that when I start the other gui app from within the plugin I don't know how to communicate with it.  I would like to do these things with it:
    1. For the spawned off app to be able to tell Adobe Acrobat to open a file in a certain location.
    2. For the spawned off app to exit if Adobe Acrobat is closed.
    3. Also if the spawned off app closes for the handles to it to be desposed of and cleaned up to avoid leaks.
    Any ideas on the easiest approach to the above behaviors?
    Here's  my code so far in the plugin:
    void StartApp1()
              STARTUPINFO info={sizeof(info)};
              PROCESS_INFORMATION processInfo;
              if (CreateProcess(NULL , "myexe.exe", NULL, NULL, TRUE, 0, NULL, NULL, &info, &processInfo))
                        ::WaitForSingleObject(processInfo.hProcess, 0);
                        CloseHandle(processInfo.hProcess);
                        CloseHandle(processInfo.hThread);
              else {
                             AVAlertNote("Couldn't luanch the exe");

  • Retriving data from database

    i want to match the value in request.getParameter("sort") to retrive my databse infromation. i did it like dat :
    rs = st.executeQuery("select * from cust_info where Acc_Name LIKE ''"+request.getParameter("sort")+"'%'");
    but tis doesnt seem to work. can anyone tell me the proper syntax?

    An alternative approach may help - use a PreparedStatement and then set the values using the PreparedStatement.set<type>(...) method.
    e.g.
    String sqlQuery = "select * from cust_info where Acc_Name LIKE ?";
    psQuery = conn.prepareStatement(sqlQuery);
    psQuery.setString(1, request.getParameter("sort") + "%");
    rs = psQuery.executeQuery();
    rs.next();
    // Process resultset here.The ?'s indicate a parameter that you are setting, all of the formatting is done for you so never use '?' just put ? and ensure the right method is used for the type of parameter.
    Remember to close the PreparedStatement and ResultSet after you have finished (in a finally clause is probably best) to avoid leaking cursors on the Database.

  • Problems with dependencies in SDM

    Hi all,
    I have some problems with the dependencies check in SDM.
    Some time ago we have created several custom PAR files for our internal Portal. As it takes some time to upload all these PAR files manually we created EAR files out of these PAR files and bundled them into an SCA file.
    As theses EAR files needs to be deployed in a certain order we managed to create specific dependencies between these EAR files.
    Up to now everything worked fine.
    But now we have a new challenge. Due to a structure change we needed to create new PAR files which change the dependency hierarchy. When we now create EAR files and bundle them to an SCA file we get an error message when trying to upload the files via SDM.
    The SDM then throws following error:
    For each of the listed SDAs (contained in the selected SCA) SDM has detected an SDA in its repository with identical development component attributes but with a different software type or with a different set of dependencies.
    example:
    in the past we had two PAR file "appA.par" and "appB.par". "appA.par" depends on "appB.par" and "appB.par" depends on the SAP Portal Runtime PAR file. (So "appB.par" needs to be deployed first).
    Now we have three PAR files "appA.par", "appB.par" and "appC.par". "appA.par" does not depend any longer from "appB.par" but from "appC.par". Trying to deploy these files now via SDM throws an error telling that SDM can't upload the SCA file as "appA.par" should depend on "appB.par" and not on "appC.par"...
    Is there any way to switch off this dependency check for custom components or to reset or avoid it somehow else.
    What I want to avoid is to undeploy all the PAR files deployed so far as the list of PAR files is very big and the SDM undeployment tool is not very handy...
    regards
    René Jurmann

    Hi,
    I don't have a good answer to your question (other than undeploy them which you would like to avoid , but what I usually recommend for PAR transport is to have a dummy portal component for each of them (in the portal-app.xml) and create an iview of it in a special folder. Then just transfer all the iviews in a transport package, select include dependencies (<yournamespace_prefix>.*) and you have a standard portal transport package with all your pars.. Beats waiting for the SDM to start up
    Dagfinn

  • Got the mic working in Skype w/Windows 7 RC 64 bit on Mac Book Pro

    I managed to get the mic working in Skype running Windows 7 RC 64 bit on my Mac Book Pro.
    It's a Skype problem. The program automatically selects the DIGITAL input. You need to change it to the RealTex internal microphone.
    From Skype, go into Tools -> Options -> Audio Settings and make sure the microphone is selected instead of the digital input.
    Works for me.

    You may need to modify the installer script that may block anything beyond certain build; or install drivers individually.
    Boot Camp 2.1 is now over a year old. There ARE newer drivers on newer later copies of OS X, both retail (10.5.6) and OEM, and in order to be "compatible" those are still 2.0.xxx versions. People have run into trouble installing their newer BC only to have BC 2.1 corrupt their install.
    Snow Leopard includes later drivers and part of BC 3.0.
    I bought Leopard (10.5.0) before I needed or wanted really to - I felt it would need six months to work out the kinks, but I also wanted 'new' Boot Camp, too. Well, it had 2.0 all right, but same drivers as Boot Camp 1.4 beta from Sept '07 and earlier.
    Windows 7 is pretty good about finding what is missing or needed, but there are some motherboard specific drivers it may not provide. Some news sites have said that later builds than 7100 have support for Nvidia logicboards and others that were missing or problematic... but I'd hold off and avoid leaked builds.
    If you can tolerate or live with limited functionality or source drivers and patch things, even the Apple installer and drivers, you may be okay.
    I'm impressed, Windows installer, update, ability to rollback, check points, and how well it runs. Much more reliable and stable and problem free. One thing I would do is make sure you have enough room, and allow 20GB / 24% free space just so you have a couple restore check points in case you need to. It is all too easy to use 10-15GB for those and come in handy.
    Any vendor that writes API and drivers has found they have their work cut out, and that of course includes Kaspersky and others.
    The first and only time I attempted to install Apple Setup Windows put up an alert "Known Incompatible" known to cause stability issues or something. And I was and generally do use the Windows 7 Compatibility Mode for installing drivers (control click).

  • Under what conditions is it safe to not close a reference?

    I am curious whether there are certain conditions where references will be automatically closed. Especially with ActiveX projects, the number of references that are opened can get very large. When I look at VB code, I see references created by initializing variables, but I don't anything explicitly closing them. Is it necessary to always close the references used in LabVIEW manually?

    For ActiveX, you must always close the reference to avoid leaks while running. Remember that an ActiveX reference is really an IUnknown pointer under the covers, which requires the AddRef() and Release() methods to be invoked (COM is a reference counting model). VB handles it for you automatically by its internal garbage collector.
    LabVIEW will automatically clean up the reference when the top-level VI goes idle but not until then.
    Brian Tyler
    http://detritus.blogs.com/lycangeek

  • Memory leak on application undeploy.

    We're creating a Spring-based web app that is using a Tomcat 7.0.33 managed Oracle database pool. We're using the ojdbc6.jar to connect (Oracle 10g but migrating to 11g later).
    When our application is undeployed in Tomcat we get probable memory leak warnings (see below). After several re-deploys we inevitably run out of PermGen space. I've tried using the ojdbc14 drivers and they didn't seem to have this problem. But we're moving to 11g so we can't use them. I have tried adding a ContextListener that closes the DBCP pool on destroy but that didn't help any. Is this a bug in the Oracle drivers? Is there any way we can mitigate this?
    17505 INFO org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean - Closing JPA EntityManagerFactory for persistence unit 'myManager'
    17515 INFO org.apache.tiles.access.TilesAccess - Removing TilesContext for context: org.springframework.web.servlet.view.tiles2.SpringTilesApplicationContextFactory$SpringWildcardServletTilesApplicationContext
    Dec 06, 2012 6:41:29 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
    SEVERE: The web application [myApp] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@1468544]) and a value of type [java.lang.Class] (value [class oracle.sql.AnyDataFactory]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    Dec 06, 2012 6:41:29 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
    SEVERE: The web application [myApp] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@d73b31]) and a value of type [java.lang.Class] (value [class oracle.sql.TypeDescriptorFactory]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    Dec 06, 2012 6:41:29 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
    SEVERE: The web application [myApp] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@13aae39]) and a value of type [java.lang.Class] (value [class oracle.sql.TypeDescriptorFactory]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    Dec 06, 2012 6:41:29 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
    SEVERE: The web application [myApp] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@18443b1]) and a value of type [java.lang.Class] (value [class oracle.sql.AnyDataFactory]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
    Dec 06, 2012 6:41:34 PM org.apache.catalina.startup.HostConfig deleteRedeployResources
    INFO: Undeploying context [myApp]

    Nevermind - It figures just after I post this I find the solution. And naturally it's not a bug in the ojdbc6.jar drivers. :-)
    It turns out our application was also including ojdbc6.jar in WEB-INF/lib. This caused Tomcat to use our jar for connections and thus the leak was formed. So not deploying ojdbc6.jar with our application (marking it as "provided" in pom.xml) lets Tomcat manage the connections and clean-up our app.

  • Best practice with Listeners to avoid memory leaks

    Hi guys,
    I'm using Javafx to develop an application. I'm creating views with fxml. I'm experiencing some memory problems perhaps because I can not understand the life cycle of the controller and the views.
    For example, the listeners that I add in the controller to the components of ui, must be removed before going out from the view?
    And in a case in which there is a inner listener? For example:
    tabellaClienti.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Cliente>() {
                   @Override
                   public void changed(ObservableValue<? extends Cliente> property, Cliente oldSelection, Cliente newSelection) {
                        seleziona(newSelection);
              });in this case the listener when is destroyed?
    I'm experiencing that I got the same view (with all components) in memory many times.
    There is a guideline to follow to be sure to avoid making mistakes?
    Thanks!

    You should either remove your listener or, if you don't know when (because you lose track of your tabellaClienti), you can use WeakChangeListener.
    http://docs.oracle.com/javafx/2/api/javafx/beans/value/WeakChangeListener.html
    But I wonder why there a leaks at all, because you listener is only in the view and not on another reference, so it can be garbaged collected.
    Note that you must have a private class variable in you view holding a reference to your ChangeListener then.
    Do you know a good tool, how you can see which objects are in memory and cannot be garbaged collected? We constantly have memory issues, too...

  • How can I avoid memory leak problem ?

    I use Jdev 10.1.2 . I have a memory leak problem with ADF .
    My application is very large . We have at least 30 application module , each application module contain many view object
    and I have to support a lot of concurrent users .
    as I know ADF stored data of view object in http session .
    and http session live is quite long . when I use application for a while It raise Ouf of Memory error .
    I am new for ADF.
    I try to use clearCache() on view object when I don't use it any more .
    and call resetState() when I don't use Application Module any more
    I don't know much about behavior of clearCache() and resetState() .
    I am not sure that It can avoid memory leak or not .
    Do you have suggestion to avoid this problem ?

    ADF does not store data in the HTTP session.
    See Chapter 28 "Application Module State Management" in the ADF Developer's Guide for Forms/4GL Developers on the ADF Learning Center at http://download-uk.oracle.com/docs/html/B25947_01/toc.htm for more information.
    See Chapter 29 "Understanding Application Module Pooling" to learn how you can tune the pooling parameters to control how many modules are used and how many modules "hang around" for what periods of time.

  • Free memory after using GetRS232ErrorString() to avoid memory leak?

    Hello,
    Is it necessary to free memory after using function GetRS232ErrorString() to avoid memory leak?
    Example 1:
    int main();
    char *strError=NULL;
    strError = GetRS232ErrorString(55); /* just an example for error message */
    free(strError ); /* Do I need to free this pointer? */
    Example 2:
    int main();
    MessagePopup ("Error", GetRS232ErrorString(55)); ; /* Will I get a memory leak with this function call? */
    BR
    Frank

    It's a pity that the documentation is indeed so poor in this case, but testing shows that it always returns the same pointer, no matter the error code, so it seems to be using an internal buffer and you are not supposed to free the string (but need to copy it before the next call to GetRS232ErrorString if you need to keep the text). It does however return a different pointer for every thread, so atl least it seems to be thread safe.
    Cheers, Marcel 

  • Best Practices for EJB--memory leak avoidance

    I an researching a memory leak. From what I can tell, we do not want to put any instance variables at the class level. This would incur a memory leak when the ejb containers creates the ejb.
    I am wondering if there are any more 'best practices' with EJBs that prevent memory leaks. A good site would help me too
    Russ

    Thank for your reply.
    You are right. I was referring to stateless session
    beans.
    What I was thinking was the following:
    1. Making parameters final unless the parameter
    r state is changed inside a method.Won't help with memory leaks. There are benefits for an object being immutable, but I don't think that it eliminates the possibility of the object being leaked.
    2. All instance variables in stateless session beans
    s should be set to null upon ejbPassivate and
    ejbRemove operations. The variables should be
    populated on ejbCreate and ejbActivate.Optimizing compilers don't need the hint of setting the reference to null. I don't think that helps, but I'm not 100% certain.
    3. Before throwing an exception at the session bean
    level, clear up all the instance variables by setting
    them to null.Shouldn't scope make it clear to the GC that the objects aren't needed? If they're all primitives, how does this help memory leaks?
    I am using a profiler to identify the objects still
    being held onto once GC, but I was hoping others with
    more experience than I would share some of their tips
    on how they avoid memory leaks.I don't know where you're getting these tips, but I don't think they're helpful.
    Collections and Singletons would be the places where I'd look. If you add a reference to an object that holds onto it in a collection and never lets go, the GC won't reclaim it.
    Singletons aren't cleaned up, because their instance is static. Anything the Singleton refers to won't be cleaned up unless the Singleton relinquishes the reference.
    Look for things like that. I think they matter more.
    %

  • How to use TorLib to avoid DNS leaks

    Dear Forum Members,
    I need some advice on how best to run Tor in Java when using TorLib to avoid DNS leaks. My difficulty is how to use the TorLib class in the code snippet below to connect to a webserver:
          String url = "http://www.abc.com/index.html",
          URL server = new URL(url);
          Properties systemProperties = System.getProperties();
          systemProperties.setProperty("socks.ProxyHost","localhost");
          systemProperties.setProperty("socks.ProxyPort",9050);
          HttpURLConnection connection = (HttpURLConnection) server.openConnection();
          ......Do I need to instantiate a new socket and how to use it to point to Tor?
    Apologies for asking Tor question in a Java Forum since I could not find the right forum. It would be great if you could direct me to one.
    Any assistance would be appreciated.
    Thanks,
    Jack

    Hi,
    unfortunately, I cannot give support to TorLib, but I can show you an alternative:
    You could use the [silvertunnel Netlib (Tor for Java library)|http://silvertunnel.org/Netlib] as follows:
    // prepare Tor connectivity
    NetLayer lowerNetLayer = NetFacade.getInstance().getNetLayerById(NetLayerIDs.TOR);
    NetlibURLStreamHandlerFactory factory = new NetlibURLStreamHandlerFactory(false);
    factory.setNetLayerForHttpHttpsFtp(lowerNetLayer);
    // create the suitable URL object
    String urlStr = "http://www.abc.com/index.html";
    URLStreamHandler handler = factory.createURLStreamHandler("http");
    URL context = null;
    URL url = new URL(context, urlStr, handler);
    // the rest of this method is as for every java.net.URL object
    URLConnection urlConnection = url.openConnection();
    urlConnection.close();This code communicates over Tor network and has no DNS leak. Docs: [HTTP over Tor in Java with silvertunnel Netlib|http://sourceforge.net/apps/trac/silvertunnel/wiki/NetlibHttp]
    Bye,
    C.

Maybe you are looking for

  • Queue name not appearing in SMW01

    Hi, we have a below mentined filter setting for material replication. MAKT     SPRAS     BT Between low and high value (Low <= x <= High)     AA     ZZ     I Inclusive defined set/array MARA     MATKL     BT Between low and high value (Low <= x <= Hi

  • What color profile for digital printing?

    Under color settings in InDesign i only find profiles for offset press but what color profile should i use if i want my document printed on a digital printer?

  • In Safari (in Gmail), plain text pasted in doesn't adopt the existing font

    When pasting plain text into Safari (Gmail), it shows up as Ariel instead of the current font in use in the e-mail (happens to be Trebuchet). It doesn't happen in Chrome.

  • Problem in raising the event DATA_CHANGED in OOP ALV

    Hi experts, I am currently having trouble in raising the event 'data_changed' in my OOP ALV . The event is triggered everytime I make changes to my editable cells but when it comes to clicking on the save button, it only calls 'data_changed_finished'

  • Is it normal behaviour of simpledateformatter???

    Is it normal bevaviour of SimpleDateFormat to allow 9 digits in year if we specify date format as "dd/mm/yyyy". I was expecting that it should be giving date in only 4 digiits.[as it does in case of  format string "dd/mm/yy" it restricts year upto 2