memory leak
I want to change url during the playing process, first, I call the shutdown to stop the original player, then ,I
create and init it, then set the url to the new player and begin to play, it work, but the memory increased during these processes. so, when i repeat the operation, memory increasing, did I deal with right? and have some other good methods? thanks!
refer to videoview.
I used the Instruments to detect the memory, and found many memores leak during the processing above, I compare to the videoview, but I didn't find any differents, the videoview call release and then openvideo, can you give me some ideas? thanks!
please give your code.
Bytes Used # Leaks Symbol Name
256 Bytes 32.6% 4 mallocz
256 Bytes 32.6% 4 SDL_CreateMutex
256 Bytes 32.6% 4 ijkmeta_create
256 Bytes 32.6% 4 ffp_create
256 Bytes 32.6% 4 ijkmp_create
256 Bytes 32.6% 4 ijkmp_ios_create
256 Bytes 32.6% 4 -[IJKFFMoviePlayerController
initWithOptions:withSegmentResolver:]
192 Bytes 24.4% 3 -[IJKVideoViewController
onClickChangeURL:]
192 Bytes 24.4% 3 main
64 Bytes 8.1% 1 -[IJKVideoViewController viewDidLoad]
64 Bytes 8.1% 1 -[IJKAppDelegate
application:didFinishLaunchingWithOptions:]
64 Bytes 8.1% 1 main
192 Bytes 24.4% 4 ijkmeta_create
192 Bytes 24.4% 4 ffp_create
192 Bytes 24.4% 4 ijkmp_create
192 Bytes 24.4% 4 ijkmp_ios_create
192 Bytes 24.4% 4 -[IJKFFMoviePlayerController
initWithOptions:withSegmentResolver:]
144 Bytes 18.3% 3 -[IJKVideoViewController
onClickChangeURL:]
144 Bytes 18.3% 3 main
48 Bytes 6.1% 1 -[IJKVideoViewController viewDidLoad]
48 Bytes 6.1% 1 -[IJKAppDelegate
application:didFinishLaunchingWithOptions:]
48 Bytes 6.1% 1 main
112 Bytes 14.2% 7 av_realloc
112 Bytes 14.2% 7 av_strdup
112 Bytes 14.2% 1 ijkmeta_append_child_l
112 Bytes 14.2% 1 ijkmeta_set_avformat_context_l
112 Bytes 14.2% 1 read_thread
112 Bytes 14.2% 1 SDL_RunThread
64 Bytes 8.1% 1 av_dict_set
48 Bytes 6.1% 3 av_malloc
48 Bytes 6.1% 3 av_mallocz
-
(IBAction)onClickChaURL:(id)sender { NSURL *theMovieURL = NULL; if (!_urlflag) { theMovieURL = [NSURL URLWithString:@"rtmp://10.242.151.24:1935/live/harold"]; _urlflag = true; } else if (_urlflag) { theMovieURL = [NSURL URLWithString:@"rtmp://10.242.151.24:1935/live/chase"]; _urlflag = false; }
[self.player shutdown]; self.player = [[IJKFFMoviePlayerController alloc] initWithContentURL:theMovieURL withOptions:nil];
[self.view addSubview:self.player.view]; [self.view addSubview:self.mediaControl];
self.mediaControl.delegatePlayer = self.player; [self.player setOpenVideoToolBox:NO]; [self.player prepareToPlay]; [self.player play]; }
please do ffp->meta == NULL in ffp_reset_internal() after free the memory ffp->meta point.
ffp->meta = NULL are already add in ffp_reset_internal() at k0.3.1version, but the problem are exist
inline static void ffp_reset_internal(FFPlayer ffp) { / ffp->is closed in stream_close() */
/* format/codec options */
av_dict_free(&ffp->format_opts);
av_dict_free(&ffp->codec_opts);
av_dict_free(&ffp->sws_opts);
av_dict_free(&ffp->player_opts);
/* ffplay options specified by the user */
av_freep(&ffp->input_filename);
ffp->audio_disable = 0;
ffp->video_disable = 0;
memset(ffp->wanted_stream_spec, 0, sizeof(ffp->wanted_stream_spec));
ffp->seek_by_bytes = -1;
ffp->display_disable = 0;
ffp->show_status = 0;
ffp->av_sync_type = AV_SYNC_AUDIO_MASTER;
ffp->start_time = AV_NOPTS_VALUE;
ffp->duration = AV_NOPTS_VALUE;
ffp->fast = 1;
ffp->genpts = 0;
ffp->lowres = 0;
ffp->decoder_reorder_pts = -1;
ffp->autoexit = 0;
ffp->loop = 1;
ffp->framedrop = 0; // option
ffp->infinite_buffer = -1;
ffp->show_mode = SHOW_MODE_NONE;
av_freep(&ffp->audio_codec_name);
av_freep(&ffp->video_codec_name);
ffp->rdftspeed = 0.02;
#if CONFIG_AVFILTER ffp->vfilters_list = NULL; ffp->nb_vfilters = 0; ffp->afilters = NULL; #endif ffp->autorotate = 1;
ffp->sws_flags = SWS_FAST_BILINEAR;
/* current context */
ffp->audio_callback_time = 0;
/* extra fields */
ffp->aout = NULL; /* reset outside */
ffp->vout = NULL; /* reset outside */
ffp->pipeline = NULL;
ffp->node_vdec = NULL;
ffp->sar_num = 0;
ffp->sar_den = 0;
av_freep(&ffp->video_codec_info);
av_freep(&ffp->audio_codec_info);
ffp->overlay_format = SDL_FCC_RV32;
ffp->last_error = 0;
ffp->prepared = 0;
ffp->auto_resume = 0;
ffp->error = 0;
ffp->error_count = 0;
ffp->start_on_prepared = 1;
ffp->max_buffer_size = MAX_QUEUE_SIZE;
ffp->high_water_mark_in_bytes = DEFAULT_HIGH_WATER_MARK_IN_BYTES;
ffp->start_high_water_mark_in_ms = DEFAULT_START_HIGH_WATER_MARK_IN_MS;
ffp->next_high_water_mark_in_ms = DEFAULT_NEXT_HIGH_WATER_MARK_IN_MS;
ffp->max_high_water_mark_in_ms = DEFAULT_MAX_HIGH_WATER_MARK_IN_MS;
ffp->current_high_water_mark_in_ms = DEFAULT_START_HIGH_WATER_MARK_IN_MS;
ffp->playable_duration_ms = 0;
ffp->pictq_size = VIDEO_PICTURE_QUEUE_SIZE_DEFAULT; // option
ffp->max_fps = 31; // option
ffp->videotoolbox = 0; // option
ffp->vtb_max_frame_width = 0; // option
ffp->vtb_async = 0; // option
ffp->vtb_wait_async = 0; // option
ffp->mediacodec = 0; // option
ffp->opensles = 0; // option
ffp->format_control_message = NULL;
ffp->format_control_opaque = NULL;
ffp->meta = NULL;
msg_queue_flush(&ffp->msg_queue);
}
when i repeat the operation above ,the log print "failed to make complete framebuffer object 8cdd"
[self.view addSubview:self.player.view];
Where do you remove subview?
no ,i don't do the operation of remove subview
SDL_VoutFreeP(&ffp->vout);
SDL_AoutFreeP(&ffp->aout);
- ffpipenode_free_p(&ffp->node_vdec); ffpipeline_free_p(&ffp->pipeline);
- ijkmeta_destroy_p(&ffp->meta);
ffp_reset_internal(ffp);
msg_queue_destroy(&ffp->msg_queue);
- ijkmeta_destroy_p(&ffp->meta);
av_free(ffp);
}
during the url change processing ,we want the playback interface not exit
ijkplayer creates new view for each instance. You must release them when you release ijkplayer.
what should we do to remove the subview, can you tell me ? thanks!
[self.player.view removeFromSuperview]
the problem is solved, thanks very much!
@wbi1987 May I ask what was your solution? I'm running into the same. The memory is growing up quickly every time an video is played by IJK Player
