anubhav94 / gstreamer-java

Automatically exported from code.google.com/p/gstreamer-java
0 stars 0 forks source link

Appsink memory leaks #112

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

//                   __ queue -> appsink (parse time stamp)
//                  /                                                           

                   __ queue -> xvimagesink (display stream)            
// httpsrc -> tee ->                                                            

                  /                                  __>>>> fakesink  [whenever 
not saving]
//                  \__ queue -> multipartdemux (dynamic pads) -> jpegdec -> 
ffmpegcolorspace -> autovideosink

  source.set("location", source_url);
                appsink.set("emit-signals", true);
                appsink.set("max-buffers", 1);
                appsink.set("drop", true); //Make this non-blocking. Meaning drop frames when queue is full
                appsink.set("sync", false);
...
...
...
...

   appsink.connect(new AppSink.NEW_BUFFER() {

                    @Override
                    public void newBuffer(AppSink as) {
                        // long seconds = appsink.getClock().getTime().getSeconds();
                        // System.out.print(seconds);

                        Buffer buffer = as.pullBuffer(); //.pullPreroll();

                        // Create a character ByteBuffer
                        CharBuffer cbuf = byteBuffer.asCharBuffer();

                        ByteBuffer byteBuffer = buffer.getByteBuffer();
                        byte[] bytearray = new byte[byteBuffer.remaining()];
                        byteBuffer.get(bytearray);
                        String strBuffer = new String(bytearray);
                        //InputStream is = new ByteArrayInputStream(bytearray);
                        // System.out.print(buffer.getSize()+"\n");
                        //  System.out.print(s+"\n");
                        /Pattern p = Pattern.compile("Date_time:");

                        try {

                        if (s != null) {
                        Matcher m = p.matcher(s);
                        if (m.find()) {
                        //System.out.println(is);
                        String[] result = p.split(s);
                        //System.out.printf("result = %s\n",result[1]);

                        //Pattern ts = Pattern.compile("[,\\-\\:\\.\\^TZ\\s]+");
                        Pattern ts = Pattern.compile("[\\-\\:\\.\\s]+");
                        Matcher m_ts = ts.matcher(result[1]);
                        if (m_ts.find()) {
                        String[] ts_str = ts.split(result[1]);
                        for (int i = 0; i < ts_str.length; i++) // System.out.printf("ts_str[%d]=%s\n",i,ts_str[i]);
                        {
                        //if (ts_str.length == 10) {
                        System.out.printf("\nDay=%s,", ts_str[1]);
                        System.out.printf("DD=%s,", ts_str[2]);
                        System.out.printf("MM=%s,", ts_str[3]);
                        System.out.printf("YYYY=%s,", ts_str[4]);
                        System.out.printf("HH=%s,", ts_str[5]);
                        System.out.printf("MM=%s,", ts_str[6]);
                        System.out.printf("SS=%s,", ts_str[7]);
                        System.out.printf("SSSSSS=%s", ts_str[8]);
                        System.out.printf("LocalTime=%s\n", ts_str[9]);

                        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ssZZZZ");
                        Date gmt = formatter.parse(ts_str[4]+"-"+ts_str[3]+"-"+ts_str[2]
                        +"T"+ts_str[5]+":"+ts_str[6]+":"+ts_str[7]+"+"+"0000");//"2011-07-19T18:23:20+0000"); ts_str[8].substring(0, 4)
                        long millisecondsSinceEpoch0 = gmt.getTime()/1000;
                        String asString = formatter.format(gmt);
                        System.out.printf(" ===== %s and \n ", asString); 
                        System.out.print(millisecondsSinceEpoch0);
                        // }
                        }

                        }
                        }

                        }

                        } catch (Exception e) {
                        System.out.println("Exception: " + e);
                        }

                        // Stream example: 

                        //Date_time: TUE:24-01-2012 18:03:10 203 LT 

                        int header_idx = strBuffer.indexOf(dateHeaderKey);
                        System.out.printf("header_idx:%s\n", header_idx);
                        if (header_idx != -1) {
                            int date_start = header_idx + dateHeaderKey.length();
                            int lt_idx = dateFormat.length();//strBuffer.indexOf(dateEndKey, date_start);
                            System.out.printf("lt_idx:%s\n", lt_idx);
                            if (lt_idx != -1) {
                                int date_end = date_start + lt_idx;
                                System.out.printf("date start: %s, end %s\n", date_start, date_end);
                                String dateStr = strBuffer.substring(date_start, date_end);
                                try {
                                    dateFormatter = new SimpleDateFormat(dateFormat);
                                    Date frameTime = dateFormatter.parse(dateStr);
                                    long millisecondsSinceEpoch0 = frameTime.getTime() / 1000;
                                    System.out.printf("date: %s\n", frameTime);
                                    System.out.printf("time: %d\n", millisecondsSinceEpoch0);
                                } catch (ParseException ex) {
                                    System.out.printf("Failed to parse: %s\n", dateStr);
                                }
                            }
                        }

                        byteBuffer.clear();
                        buffer.dispose();
                        buffer = null;

                        as = null;
                        byteBuffer = null;
                    }
                });

What is the expected output? What do you see instead?

Memory keeps increasing minute by minute

Have you tried to verify this is a gstreamer-java specific issue, and not a
problem with the gstreamer framework itself?
yes.

What version of the product are you using? On what operating system?
1.5

Please provide any additional information below.

Original issue reported on code.google.com by enthusia...@gmail.com on 12 Sep 2012 at 9:39

GoogleCodeExporter commented 9 years ago
could you find the part of your code which eat the memory?

Original comment by lfar...@lfarkas.org on 26 Nov 2012 at 12:30