Oracle 9.2 and memory leak detection

Hi All.
I have found the following error in trace file
after shutdown database.
=================================================================
/.../udump/cpaw_ora_4427.trc
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
ORACLE_HOME = /.../product/9.2.0
System name: Linux
Node name: host.com
Release: 2.4.18-10bigmem
Version: #1 SMP Wed Aug 7 10:26:52 EDT 2002
Machine: i686
Instance name: orcl
Redo thread mounted by this instance: 0 <none>
Oracle process number: 10
Unix process pid: 4427, image: [email protected] (TNS V1-V3)
*** SESSION ID:(9.3) 2002-10-10 14:17:14.265
Archiving is disabled
Archiving is disabled
******** ERROR: SGA memory leak detected 16 ********
KGH Latch Directory Information
ldir state: 2 next slot: 39
Slot [  1] Latch: 0x50005be8 Index: 1 Flags: 3 State: 2 next: (nil)
<...>
=====================================================================
Linux RedHat 7.3 (db works in archivelog mode).
How can I correct this?
Thanks in advance.
Best regards,
Andrey Demchenko.

Thanks for the answers. The oci8.dll is uncommented naturally. Otherwise it would start up just fine, but I couldn't use the database functions.
I got it working by installing 5.1.6, but replacing the oci8.dll with the one from the 5.1.0 -version. It's a very... desperate... solution, but at least it works.
I'm gonna have to try to sell the idea of using the 10g client to our DBA. I don't think though, that he'll be very enthusiastic to set it up on our production servers. We'll see.

Similar Messages

  • UGA memory leak detected 1488

    Hi all,
    I am getting the following error in the database alert log.
    ORA-00600: internal error code, arguments: [729], [2216], [space leak], [], [], [], [], []
    when checked the trace file in which the details are dumped. The error line says
    *** 2004-01-07 18:09:00.002
    *** SESSION ID:(123.21632) 2004-01-07 18:08:59.981
    ******** ERROR: UGA memory leak detected 2216 ********
    HEAP DUMP heap name="session heap" desc=0x80000001000b10f0
    extent sz=0x10a8 alt=32767 het=32767 rec=0 flg=3 opc=3
    parent=8000000100007450 owner=c00000003785c750 nex=0 xsz=0x4098
    EXTENT 0
    Can anyone help me in this issue.
    Thanks in advance.
    Regards
    Shoyeb

    Generally error ORA-00600 is very complex to understand and in almost all cases that error is tried with Oracle Support. http://metalink.oracle.com . You have to have an account to open an iTAR and so on.
    Joel P�rez

  • PGA memory leak detected

    Hi all,
    I using Database version 9.0.2.1 on Windows.
    In Udump\.....trace file have a message:
    *** 2004-04-11 13:28:58.000
    *** SESSION ID:(4.1) 2004-04-11 13:28:57.000
    ******** ERROR: PGA memory leak detected 10340 > 6004 ********
    HEAP DUMP heap name="pga heap" desc=001CDF10 ....
    and then about 1-2 hours, my database is down (not connect) (error: ORA=3113: end of file communicational...)
    I think, cause is PGA memory too large, may be ? I set value of PGA = 80-100 MB.
    My server has 1.5GB RAM, (SGA = 900, Shared Mem=500, Buffer mem= 150..). It's correct ?
    Please help me to resolve this problem.!!!!!
    Thanks
    [email protected]

    Hi ER,
    It seems that you need to Update Patch - 9.2.0.6 which will solve this PGA Memory Leak!
    Check this Doc ID: Note:283897.1 in Metalink!
    Ravi Prakash

  • Effective tool for GDI memory leaks detection

    Hello!
    Would you advice me some effective tool for GDI memory leaks and run-time errors detection in VC++?
    Thanks!

    926007 wrote:
    This forum is about Java.No, this forum is about C++.
    Please notice the name of the forum: "Solaris Studio *C++*", under the category "Application Development in C, C++, and Fortran".
    There are other forums for Java, listed here:
    https://forums.oracle.com/forums/category.jspa?categoryID=285

  • Oracle JDBC Thin Driver Memory leak in scrollable result set

    Hi,
    I am using oracle 8.1.7 with oracle thin jdbc driver (classes12.zip) with jre 1.2.2. When I try to use the scrollable resultset and fetch records with the default fetch size, I run into memory leaks. When the records fetched are large(10000 records) over a period of access I get "outofmemory" error because of the leak. There is no use increasing the heap size as the leak is anyhow there.
    I tried using optimizeit and found there is a huge amout of memory leak for each execution of scrollable resultsets and this memory leak is propotional to the no of records fetched. This memory leak is not released even when i set the resultset,statement objects to null. Also when i use methods like scrollabelresultset.last() this memory leak increases.
    So is this a problem with the driver or i am doing some wrong.
    If some of you can help me with a solution to solve this it would be of help. If needed i can provide some statistics of these memory leaks using optimize it and share the code.
    Thanks
    Rajesh

    This thread is ancient and the original was about the 8.1.7 drivers. Please start a new thread. Be sure to include driver and database versions, stack traces, sample code and why you think there is a memory leak.
    Douglas

  • Custom MediaStreamSource and Memory Leaks During SampleRequested

    Greetings,
    I have a nasty memory leak problem that is causing me to pull my hair out.
    I'm implementing a custom MediaStreamSource along with MediaTranscoder to generate video to disk. The frame generation operation occurs in the SampleRequested handler (as in the MediaStreamSource example). No matter what I do - and I've tried a
    ton of options - inevitably the app runs out of memory after a couple hundred frames of HD video. Investigating, I see that indeed GC.GetTotalMemory reports an increasing, and never decreasing, amount of allocated RAM. 
    The frame generator in my actual app is using RenderTargetBitmap to get screen captures, and is handing the buffer to MediaStreamSample.CreateFromBuffer(). However, as you can see in the example below, the issue occurs even with a dumb allocation
    of RAM and no other actual logic. Here's the code:
    void _mss_SampleRequested(Windows.Media.Core.MediaStreamSource sender, MediaStreamSourceSampleRequestedEventArgs args)
    if ( args.Request.StreamDescriptor is VideoStreamDescriptor )
    if (_FrameCount >= 3000) return;
    var videoDeferral = args.Request.GetDeferral();
    var descriptor = (VideoStreamDescriptor)args.Request.StreamDescriptor;
    uint frameWidth = descriptor.EncodingProperties.Width;
    uint frameHeight = descriptor.EncodingProperties.Height;
    uint size = frameWidth * frameHeight * 4;
    byte[] buffer = null;
    try
    buffer = new byte[size];
    // do something to create the frame
    catch
    App.LogAction("Ran out of memory", this);
    return;
    args.Request.Sample = MediaStreamSample.CreateFromBuffer(buffer.AsBuffer(), TimeFromFrame(_FrameCount++, _frameSource.Framerate));
    args.Request.Sample.Duration = TimeFromFrame(1, _frameSource.Framerate);
    buffer = null; // attempt to release the memory
    videoDeferral.Complete();
    App.LogAction("Completed Video frame " + (_FrameCount-1).ToString() + "\n" +
    "Allocated memory: " + GC.GetTotalMemory(true), this);
    return;
    It usually fails around frame 357, with GC.GetTotalMemory() reporting 750MB allocated.
    I've tried tons of work-arounds, none of which made a difference. I tried putting the code that allocates the bytes in a separate thread - no dice.  I tried Task.Delay to give the GC a chance to work, on the assumption that it just had no time
    to do its job. No luck.
    As another experiment, I wanted to see if the problem went away if I allocated memory each frame, but never assigned it to the MediaStreamSample, instead giving the sample (constant) dummy data. Indeed, in that scenario, memory consumption stayed
    constant. However, while I never get an out-of-memory exception, RequestSample just stops getting called around frame 1600 and as a result the transcode operation never actually returns to completion.
    I also tried taking a cue from the SDK sample which uses C++ entirely to generate the frame. So I passed the buffer as a Platform::Array<BYTE> to a static Runtime extension class function I wrote in C++.
    I won't bore you with the C++ code, but even directly copying the bytes of the array to the media sample using memcpy still had the same result! It seems that there is no way to communicate the contents of the byte[] array to the media sample without
    it never being released.
    I know what some will say: the difference between my code and the SDK sample, of course, is that the SDK sample generates the frame _entirely_ in C++, thus taking care of its own memory allocation and deallocation. Because I want to get
    the data from RenderTargetBitmap, this isn't an option for me. (As a side note, if anyone knows if there's a way to get the contents of an RT Window using DirectX, that might work too, but I know this is not a C++ forum, so...). But more importantly,
    MediaStreamSource and MediaStreamSample are managed classes that appear to allow you to generate custom frames using C# or other managed code. The MediaStreamSample.CreateFromBuffer function appears to be tailored for exactly what I want. But there appears
    to be no way to release the buffer when giving the bytes to the MediaStreamSample. At least none that I can find.
    I know the RT version of these classes are new to Windows 8.1, but I did see other posts going back 3 years discussing a similar issue in Silverlight. That never appears to have been resolved.
    I guess the question boils down to this: how do I safely get managed data, allocated during the SampleRequested handler, to the MediaStreamSample without causing a memory leak? Also, why would the SampleRequested handler just stop getting called
    out of the blue, even when I artificially eliminate the memory leak problem?
    Thanks so much for all input!

    Hi Rob - 
    Thanks for your quick reply and for clarifying the terminology. 
    In the Memory Usage test under Analyze/Performance and Diagnostics (is that what you mean?) it's clear that each frame of video being created is not released from memory except when memory consumption gets very high. GC will occasionally kick in, but eventually
    it succumbs.
    Interestingly, if I reduce the frame size substantially, say 320x240, it never runs out of RAM no matter how many frames I throw at it. The Memory Usage test, however, shows the same pattern. But this time the GC can keep up and release the RAM.
    After playing with this ad nauseum,  I am fairly convinced I know what the problem is, but the solution still escapes me. It appears that the Transcoder is requesting frames from the MediaStreamSource (and the MediaStreamSource is providing them via
    my SampleRequested handler) faster than the Transcoder can write them to disk and release them. Why would this be happening? The MediaStreamSource.BufferTime property is - I thought - used to prevent this very problem. However, changing the BufferTime seems
    to have no effect at all - even changing it to ZERO doesn't change anything. If I'm right, this would explain why the GC can't do its job - it can't release the buffers I'm giving to the Transcoder via SampleRequested because the Transcoder won't give them
    up until it's finished transcoding and writing them to disk. And yet the transcoder keeps requesting samples until there's no more memory to create them with.
    The following code, which I made from scratch to illustrate my scenario, should be air-tight according to everything I've read. And yet, it still runs out of memory when the frame size is too large. 
    If you or anyone else can spot the problem in this code, I'd be thrilled to hear it. Maybe I'm omitting a key step with regard to getting the deferral? Or maybe it's a bug in the back-end? Can I "slow down" the transcoder and force it to release samples
    it's already used?
    Anyway here's the new code, which other than App.cs is everything. So if I'm doing something wrong it will be in this module:
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Threading.Tasks;
    using System.Linq;
    using System.Runtime.InteropServices.WindowsRuntime;
    using System.Diagnostics;
    using Windows.Foundation;
    using Windows.Foundation.Collections;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    using Windows.UI.Xaml.Controls.Primitives;
    using Windows.UI.Xaml.Data;
    using Windows.UI.Xaml.Input;
    using Windows.UI.Xaml.Media;
    using Windows.UI.Xaml.Navigation;
    using Windows.UI.Popups;
    using Windows.Storage;
    using Windows.Storage.Pickers;
    using Windows.Storage.Streams;
    using Windows.Media.MediaProperties;
    using Windows.Media.Core;
    using Windows.Media.Transcoding;
    // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
    namespace MyTranscodeTest
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    MediaTranscoder _transcoder;
    MediaStreamSource _mss;
    VideoStreamDescriptor _videoSourceDescriptor;
    const int c_width = 1920;
    const int c_height = 1080;
    const int c_frames = 10000;
    const int c_frNumerator = 30000;
    const int c_frDenominator = 1001;
    uint _frameSizeBytes;
    uint _frameDurationTicks;
    uint _transcodePositionTicks = 0;
    uint _frameCurrent = 0;
    Random _random = new Random();
    public MainPage()
    this.InitializeComponent();
    private async void GoButtonClicked(object sender, RoutedEventArgs e)
    Windows.Storage.Pickers.FileSavePicker picker = new Windows.Storage.Pickers.FileSavePicker();
    picker.FileTypeChoices.Add("MP4 File", new List<string>() { ".MP4" });
    Windows.Storage.StorageFile file = await picker.PickSaveFileAsync();
    if (file == null) return;
    Stream outputStream = await file.OpenStreamForWriteAsync();
    var transcodeTask = (await this.InitializeTranscoderAsync(outputStream)).TranscodeAsync();
    transcodeTask.Progress = (asyncInfo, progressInfo) =>
    Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
    _ProgressReport.Text = "Sourcing frame " + _frameCurrent.ToString() + " of " + c_frames.ToString() +
    " with " + GC.GetTotalMemory(false).ToString() + " bytes allocated.";
    await transcodeTask;
    MessageDialog dialog = new MessageDialog("Transcode completed.");
    await dialog.ShowAsync();
    async Task<PrepareTranscodeResult> InitializeTranscoderAsync (Stream output)
    _transcoder = new MediaTranscoder();
    _transcoder.HardwareAccelerationEnabled = false;
    _videoSourceDescriptor = new VideoStreamDescriptor(VideoEncodingProperties.CreateUncompressed( MediaEncodingSubtypes.Bgra8, c_width, c_height ));
    _videoSourceDescriptor.EncodingProperties.PixelAspectRatio.Numerator = 1;
    _videoSourceDescriptor.EncodingProperties.PixelAspectRatio.Denominator = 1;
    _videoSourceDescriptor.EncodingProperties.FrameRate.Numerator = c_frNumerator;
    _videoSourceDescriptor.EncodingProperties.FrameRate.Denominator = c_frDenominator;
    _videoSourceDescriptor.EncodingProperties.Bitrate = (uint)((c_width * c_height * 4 * 8 * (ulong)c_frDenominator) / (ulong)c_frNumerator);
    _frameDurationTicks = (uint)(10000000 * (ulong)c_frDenominator / (ulong)c_frNumerator);
    _frameSizeBytes = c_width * c_height * 4;
    _mss = new MediaStreamSource(_videoSourceDescriptor);
    _mss.BufferTime = TimeSpan.FromTicks(_frameDurationTicks);
    _mss.Duration = TimeSpan.FromTicks( _frameDurationTicks * c_frames );
    _mss.Starting += _mss_Starting;
    _mss.Paused += _mss_Paused;
    _mss.SampleRequested += _mss_SampleRequested;
    MediaEncodingProfile outputProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Ntsc);
    outputProfile.Audio = null;
    return await _transcoder.PrepareMediaStreamSourceTranscodeAsync(_mss, output.AsRandomAccessStream(), outputProfile);
    void _mss_Paused(MediaStreamSource sender, object args)
    throw new NotImplementedException();
    void _mss_Starting(MediaStreamSource sender, MediaStreamSourceStartingEventArgs args)
    args.Request.SetActualStartPosition(new TimeSpan(0));
    /// <summary>
    /// This is derived from the sample in "Windows 8.1 Apps with Xaml and C# Unleashed"
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="args"></param>
    void _mss_SampleRequested(MediaStreamSource sender, MediaStreamSourceSampleRequestedEventArgs args)
    if (_frameCurrent == c_frames) return;
    var deferral = args.Request.GetDeferral();
    byte[] frameBuffer;
    try
    frameBuffer = new byte[_frameSizeBytes];
    this._random.NextBytes(frameBuffer);
    catch
    throw new Exception("Sample source ran out of RAM");
    args.Request.Sample = MediaStreamSample.CreateFromBuffer(frameBuffer.AsBuffer(), TimeSpan.FromTicks(_transcodePositionTicks));
    args.Request.Sample.Duration = TimeSpan.FromTicks(_frameDurationTicks);
    args.Request.Sample.KeyFrame = true;
    _transcodePositionTicks += _frameDurationTicks;
    _frameCurrent++;
    deferral.Complete();
    Again, I can't see any reason why this shouldn't work. You'll note it mirrors pretty closely the sample in the Windows 8.1 Apps With Xaml Unleashed book (Chapter 14). The difference is I'm feeding the samples to a transcoder rather than a MediaElement (which,
    again should be no issue).
    Thanks again for any suggestions!
    Peter

  • XSLT processing and Memory Leak

    I have the following code for a Simple XSLT Transformation from one form of XML to another, the Size of the XML and the XSLT file are very small( few KB).
    As you can see I'm explicitly setting everything to null just to make sure the objects get GC'd.
    When I run the transformation on my local m/c running Windows XP on WSAD5.0 there are no memory leak issues, but when I deploy the Same app on our Server running WSAD 5.1 on Solaris, I see memory issues and finally throws an OutOfMemory Exception.
    Any Ideas would be appreciated.
         public String translate( String xml, String xsltFileName) throws Exception{
              String xmlOut = null;
              File fXslt = null;
              ByteArrayOutputStream baos = null;
              javax.xml.transform.Source xmlSource = null;
              javax.xml.transform.Source xsltSource = null;
              javax.xml.transform.Result result = null;
              InputStream isXML = null;
              javax.xml.transform.TransformerFactory transFact = null;
              javax.xml.transform.Transformer trans = null;
              Templates cachedXSLT = null;
              try{
              //     String classname = System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl");
                   String classname = System.getProperty("javax.xml.transform.TransformerFactory");
                   System.out.println( "******* TRANSFORMER CLASS ***** = "+classname);
                   isXML = new ByteArrayInputStream( xml.getBytes());
                   fXslt = new File(xsltFileName);
                   baos = new ByteArrayOutputStream();
                   xmlSource =
                             new javax.xml.transform.stream.StreamSource( isXML);
                   xsltSource =
                             new javax.xml.transform.stream.StreamSource( fXslt);
                   result =
                             new javax.xml.transform.stream.StreamResult( baos);
                   // create an instance of TransformerFactory
                   transFact = javax.xml.transform.TransformerFactory.newInstance();
                   //transFact.setAttribute("http://xml.apache.org/xalan/features/incremental", Boolean.TRUE);
                   cachedXSLT = transFact.newTemplates(xsltSource);
                   trans = cachedXSLT.newTransformer();
                   //trans =     transFact.newTransformer(xsltSource);
                   trans.transform(xmlSource, result);
                   xmlOut = baos.toString();
    System.out.println("xmlout=***" + xmlOut);
              catch( Exception e){
                   System.out.println( e.getMessage());
                   throw e;
              finally{
                   trans = null;
                   //transFact = null;
                   result = null;
                   xsltSource = null;
                   xmlSource = null;
                   baos.close();
                   baos = null;
                   fXslt = null;
                   isXML.close();
                   isXML = null;
              return xmlOut;
         }

    scream3r wrote:
    All code work's as well, but i have a memory leak by using structure (by creating a new MyStructure());Presumably this really is java code. As such the following are the only possibilities
    1. You do not have a memory leak. You are misreading a tool (probably task manager) and assuming a leak exists when it doesn't.
    2. You need to call something either on MyStructure or by passing it to another class to free it. See the documentation.
    3. The leak is caused by something else.

  • PrinterJob and Memory Leak

    I have encounter a serious memory leak when printing in Java. When the following code is compiled into a 'jar' (1.4.x and 1.5.x) and run, the Print process consumes roughly 4 Mb and never gives it back. Does anybody have a solution for recovering the lost memory?
    import java.awt.*;
    import java.awt.print.*;
    public class BasicPrint extends JComponent implements Printable {
    public int print(Graphics g, PageFormat pf, int pageIndex) {
    if (pageIndex > 0) {
    return Printable.NO_SUCH_PAGE;
    Graphics2D g2d = (Graphics2D)g;
    g2d.translate(pf.getImageableX(), pf.getImageableY());
    g2d.draw3DRect(20,50,100,50,true)
    return Printable.PAGE_EXISTS;
    public static void main(String[] args) {
    PrinterJob pjob = PrinterJob.getPrinterJob();
    PageFormat pf = pjob.defaultPage();
    pjob.setPrintable(new BasicPrint(), pf);
    try {
    pjob.print();
    } catch (PrinterException e) {
    //// You will need to set up a break point after this to examine the consequences on
    //// Memory
    }

    The setting is an option that's used on the java command, for instance:
    java -XX:MaxHeapFreeRatio=70 <yourClassName>See the results returned by the search on the option name:
    http://www.google.com/search?q=XX:MaxHeapFreeRatio

  • Struts, FormFile and memory leak

    Hi All
    I have a page, where file upload input is used.
    This page entering/submit leads to memory leak. /does not matter with or without file to upload/
    Size of wasted memory is increased with increasing html inputs count in this page.
    I used tomcat 5.0.25 + struts 1.2.4 + jdk 1.5.0_01
    Do you have any ideas?

    try using updated versions of tomcat and struts? that's what i would do.

  • Ringtones OS6 and memory leak

    Hello, a few weeks ago I updated to OS6. I found that the ringtones from the previous OS were gone so I installed them back with this link
    http://mobile.blackberry.com/resources/mbc/downloads/ringtones/drm/net_rim_bb_medialoader_ringtones_...
    Now I want to delete them again because of the memory leak, but I don't know how to do it? The ringtones seem to be locked and I can't access them. Is there any way to unlock them or get access to them with the Blackberry desktop software? Thanks!

    scream3r wrote:
    All code work's as well, but i have a memory leak by using structure (by creating a new MyStructure());Presumably this really is java code. As such the following are the only possibilities
    1. You do not have a memory leak. You are misreading a tool (probably task manager) and assuming a leak exists when it doesn't.
    2. You need to call something either on MyStructure or by passing it to another class to free it. See the documentation.
    3. The leak is caused by something else.

  • JNA Structures and memory leak

    Hi all.
    Sorry my JNA question in JNI forum, but i think it's exactly that forum for this.
    My question:
    I use an WinAPI function, and pass a Structure into the function.
    Calling of this function turning in "While" cycle, for example:
    public void getData() {
        MyStructure structure = new MyStructure();
        anWinAPI_Function(structure);
        Form.jLabel1.setText("use some data from this structure: " + structure.Data);
    }All code work's as well, but i have a memory leak by using structure (by creating a new MyStructure());
    I really know that, becose if use an int[] there is no memory leak, but i have too many WinAPI functions and can't use this way.
    Methods clear() and finalize() don't give th effect.
    Sorry for my english, hope that somebody can help me, thank's =)

    scream3r wrote:
    All code work's as well, but i have a memory leak by using structure (by creating a new MyStructure());Presumably this really is java code. As such the following are the only possibilities
    1. You do not have a memory leak. You are misreading a tool (probably task manager) and assuming a leak exists when it doesn't.
    2. You need to call something either on MyStructure or by passing it to another class to free it. See the documentation.
    3. The leak is caused by something else.

  • Callbacks without excessive thread creation and memory leaks?

    Hi JNI experts,
    I haven't done any serious JNI programming in a couple years and I'm currently stuck with a tricky JNI problem:
    My JNI code is connected to a system driver and needs to do frequent callbacks into Java code. The standard way of doing this involves calling AttachCurrentThread and DetachCurrentThread before/after the callback to Java code. However, I noticed that AttachCurrentThread creates a new java.lang.Thread each time it is invoked. Let's just say that the callback is invoked from JNI very freqently, and creating a new Thread each time that happens is not acceptable behavior for my application. Among other things, it prevents me from using the Eclipse debugger because the large number of threads being created and destroyed effectively locks up Eclipse's debugger UI. Also, it creates a CPU load that is way higher than it should be for a light-weight operation.
    So, I deviated from the standard Attach/DetachCurrentThread pattern and moved the DetachCurrentThread to code that is only called when the native JNI service is terminated. As that effectively renders repeated AttachCurrentThread calls a no-op, the problem of excessive creation and destruction of threads went away, but instead I had a memory leak on my hands now. The JNI code needs to create some Java objects because it's easier to create those objects right away rather than passing a bunch of primitives to Java and assembling them into objects there. When I moved the DetachCurrentThread, those newly created objects were no longer garbage-collected even after the Java code had released all references.
    When you print the stack trace of the Java callback method there is always only one frame on the stack (since it is being invoked directly from JNI). However, I suspect that older stack frames from previous invocations keep hanging around somewhere else in memory if DetachCurrentThread is not called. In other words, moving DetachCurrentThread out of the callback is an even worse option. I tried using PopLocalFrame to get rid of left over stack frames, but that didn't seem to work.
    So, my question is: is there a way to make (natively initiated) callbacks from JNI to Java without memory leaks and without creating a new thread each time? Would it work if I created my own native thread that runs some sort of dispatch loop? What other options are there?
    Thanks for any ideas!

    Thanks for the quick reply, ejp! :-)
    Your comments were very helpful; let me clarify a few things:
    I don't know where you get this 'standard Attach/DetachCurrentThread pattern', but if the native callbacks always happen on the same native thread, you only need to attach it once when you get the first callback, and detach it when you get the last, if you can tell. ;-)Yes, the callback is always coming from the same native thread, but, unfortunately, I cannot tell when I get the last callback, and essentially the native service keeps running as long as the VM is running. When I say "standard pattern" I'm referring to the fact that pretty much every book, tutorial, or web site that talks about JNI callbacks shows code snippets where AttachCurrentThread is called, then the callback, and then DetachCurrentThread.
    The JNI code needs to create some Java objects because it's easier to create those objects right away rather than passing a bunch of primitives to Java and assembling them into objects there.Is it really? Are you sure?I'm pretty sure in this case, though your point is well taken. The native API that calls my JNI code produces packets of that contain about 15 pieces of information of different types (ints, longs, doubles). Several packets may arrive together in a single group. Handling the data on the Java side requires a Java callback method with 15 parameters for a single packet, and it's hard to reconstruct which packets belong to one group at that point. Creating corresponding Java objects in JNI and passing them inside an array to the callback function indeed turned out to be easier.
    I don't think just 'moving' the DetachCurrentThread is correct. You need to attach the thread that is doing the callbacks, as often as necessary but no oftener, and detach it when you can.I think I found the solution: my native code is starting a separate dispatcher thread that, as you suggested, attaches itself only once and then enters a dispatcher loop. The low-level call back function notifies that thread of new data via the standard Pthread API. The detach happens in JNI_OnUnload. This works without creating a new thread each time and garbage-collects the created objects properly. As the dispatcher method essentially never returns I also had to insert some DeleteLocalRef calls, because otherwise the local references prevented garbage collection.
    So, for now, it looks like I'm good to go. Thanks again for the reply!

  • Safari + Javascript = Slowdown and Memory Leak?

    I've pinned down what I think is some problem with Safari and Javascript.
    If I leave Safari open for over 24 hours, with several pages open in tabs, in Activity Monitor Safari shows about 1.38Gig of VM and Safari is molasses slow.
    Turning off Javascript immediately restores the speed in Safari but the HUGE VM usage remains.
    So, I turned off Javascript, relaunched Safari, opened the exact same sites in tabs and left Safari sitting there for 24+ hours. It's now using only 203MBs of VM and it's still swishy fast as it should be.
    It seems like a problem between Safari and Javascript. Can anyone else confirm this phenomena before I send an official report to Apple?
    Thanks:)

    Confirmed. Running Safari with the Debug option on will tell you that there are some memory leaks with JavaScript objects.

  • Applet load and memory leak

    what are some methods to load an applet faster that is on the local machine? also, are there any applications to test for memory leaks? and are there ways to invoke garbage collection with code? thanx in advance.

    Applet on the local machine will load faster because file is already there
    use System.gc() to do a garbage collection

  • IOS and Memory Leaks

    How do you ensure that AIR on iOS does not leak memory and how do you trace 'leak' alerts to their source? Below is a table with a bunch of leak data, but I don't see how you could trace it back to your code and find the leak. I have tried making sure variables are de-referenced when finished with them, and event listeners are either removed or weak-referenced(allows objects to be garbage collected when the listener is the last thing referencing them).
    I would like to get any and all leaks out of my app so that I can submit it to the App Store.
    Edit: The leak table is from what it showed in the Apple 'Instruments' tool on my Mac when scanning the app running on my phone.
    Edit 2: I'm not sure how to interpret this leak data from Instruments. My app is running within the 'captive' AIR runtime on the iPhone, so theoretically I would think that any leaks in my app would stay allocated in the AIR captive runtime and not show up here. I thought maybe I should be monitoring the 'Allocations' section of the tool for notable changes in the total allocations since un-garbage-collected stuff would stay contained within AIR. If it is showing leak data in the 'leaks' section, does that mean the AIR runtime itself is leaking? None of the functions or libraries or identifiers or whatever they are listed in the leak data match stuff that I wrote, so maybe they are parts of the 'AIR engine'.
    Leaked Object
    Address
    Size
    Responsible Library
    Responsible Frame
    NSCFString
    60
    < multiple >
    960
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x154a73f0
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x154a73f0
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x154a73f0
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1549ee40
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1549ee40
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1549ee40
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1549ee40
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1549ee40
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1549ee30
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1549ee30
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1549ee30
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1549ee30
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1549ee30
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1549d980
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1549d980
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1549d980
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1549d980
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1549d980
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1549d6d0
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1549d6d0
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1549d6d0
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1549d6d0
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1548b800
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1548b800
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1548b800
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1548b800
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1548b070
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1548b070
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1548b070
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1548b070
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1548b070
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x154810f0
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x154810f0
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x154810f0
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x154810f0
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x154810f0
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x154810f0
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1547ccd0
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1544dfd0
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x1544dfd0
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x11637340
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x11637330
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x11637330
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x11637330
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x11626520
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x11626520
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x11626520
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x11626520
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x11615610
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x11615610
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0x11615610
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0xda84d0
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0xda84c0
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0xda84c0
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0xd905c0
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0xd7a150
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0xd67920
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0xd67920
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0xd67920
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    NSCFString
    0xd31670
    16
    QuartzCore
    CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long)
    GeneralBlock-16
    4
    < multiple >
    64
    libGLProgrammability.dylib
    std::vector<TSymbolTableLevel*, std::allocator<TSymbolTableLevel*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<TSymbolTableLevel**, std::vector<TSymbolTableLevel*, std::allocator<TSymbolTableLevel*> > >, TSymbolTableLevel* const&)
    GeneralBlock-16
    0x1160c700
    16
    libGLProgrammability.dylib
    std::vector<TSymbolTableLevel*, std::allocator<TSymbolTableLevel*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<TSymbolTableLevel**, std::vector<TSymbolTableLevel*, std::allocator<TSymbolTableLevel*> > >, TSymbolTableLevel* const&)
    GeneralBlock-16
    0x1160c700
    16
    libGLProgrammability.dylib
    std::vector<TSymbolTableLevel*, std::allocator<TSymbolTableLevel*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<TSymbolTableLevel**, std::vector<TSymbolTableLevel*, std::allocator<TSymbolTableLevel*> > >, TSymbolTableLevel* const&)
    GeneralBlock-16
    0x1160c700
    16
    libGLProgrammability.dylib
    std::vector<TSymbolTableLevel*, std::allocator<TSymbolTableLevel*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<TSymbolTableLevel**, std::vector<TSymbolTableLevel*, std::allocator<TSymbolTableLevel*> > >, TSymbolTableLevel* const&)
    GeneralBlock-16
    0x1160c700
    16
    libGLProgrammability.dylib
    std::vector<TSymbolTableLevel*, std::allocator<TSymbolTableLevel*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<TSymbolTableLevel**, std::vector<TSymbolTableLevel*, std::allocator<TSymbolTableLevel*> > >, TSymbolTableLevel* const&)
    GeneralBlock-16
    3
    < multiple >
    48
    libGLProgrammability.dylib
    GetSymbolTable(int)
    GeneralBlock-16
    0xd638f0
    16
    libGLProgrammability.dylib
    GetSymbolTable(int)
    GeneralBlock-16
    0xd638f0
    16
    libGLProgrammability.dylib
    GetSymbolTable(int)
    GeneralBlock-16
    0xd638f0
    16
    libGLProgrammability.dylib
    GetSymbolTable(int)
    GeneralBlock-16
    0xd8dca0
    16
    libGLProgrammability.dylib
    std::vector<TSymbolTableLevel*, std::allocator<TSymbolTableLevel*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<TSymbolTableLevel**, std::vector<TSymbolTableLevel*, std::allocator<TSymbolTableLevel*> > >, TSymbolTableLevel* const&)

    As I said in the post, the stuff reported in leaks doesn't match any of my variable or function names. It just shows generic stuff for the 'Responsible Library/Frame', such as GetSymbolTable(int) or QuartzCore. I didn't name anything in my code by those names. Quartz, I believe, is the stuff used to draw vectors on iOS, and the other things like 'TSymbolTableLevel' are not names I used either.
    So I am not sure if this is my code leaking memory or the AIR rumtime itself leaking memory, or how you would go about interpreting Instruments reports on an AIR based app. My theory is that any stuff not garbage collected and leaked within the AIR runtime should be contained within the runtime wouldn't show up in Instruments as a leak, so I don't know if there is anything I can do within my code to make the 'leaks' dissappear or not.
    There is a ton of stuff going on in my code, events and functions calling or initiating other functions and such, so it isnt as simple as just looking at what code would be fired at the time the leak shows up to figure out what piece of code the leak occured at.

Maybe you are looking for