CI 묻고 답하기

제목 별짓다해도 답이 안나오는에러네요. Trying to get property of non-object
글쓴이 눈꽃 작성시각 2012/09/06 09:40:30
댓글 : 4 추천 : 0 스크랩 : 0 조회수 : 17289   RSS
CI 버전 2.0.3을 사용하고있습니다.
서너달정도 아무런 에러없이 잘 돌아가고있었는데 답이 안나오는게 있어서 이렇게 질문드립니다.

아래의 스크린샷과같은 에러가 발생하고있습니다.
정상적으로 페이지가 호출이될때가 있으며 저런메세지가 뜰때가 있습니다.
같은 페이지를 계속 새로고침하면 5번에 1번꼴로 아래의 에러메세지가 뿌려지네요.

apache를 재시작하면 이 에러가 몇일동안은 발생하지않지만 어느순간이되면 또발생하네요.

-_-; 이런경험있으신분있으세요? 어떻게 해결해야할지.. 난감하네요..


위 스크린샷의 에러가 발생하는위치의 코드입니다.
/system/core/Config.php


system/core/Hooks.php  : 진하게 표시된곳이 에러발생라인임니다. 

 function _call_hook($which = '')
 {
  if ( ! $this->enabled OR ! isset($this->hooks[$which])) // 에러발생라인
  {
   return FALSE;
  }

  if (isset($this->hooks[$which][0]) AND is_array($this->hooks[$which][0]))
  {
   foreach ($this->hooks[$which] as $val)
   {
    $this->_run_hook($val);
   }
  }
  else
  {
   $this->_run_hook($this->hooks[$which]);
  }

  return TRUE;
 }
system/core/Router.php : 진하게 표시된곳이 에러발생라인임니다.
function _set_routing()
 {
  // Are query strings enabled in the config file?  Normally CI doesn't utilize query strings
  // since URI segments are more search-engine friendly, but they can optionally be used.
  // If this feature is enabled, we will gather the directory/class/method a little differently
  $segments = array();
  if ($this->config->item('enable_query_strings') === TRUE AND isset($_GET[$this->config->item('controller_trigger')]))
  {
   if (isset($_GET[$this->config->item('directory_trigger')]))
   {
    $this->set_directory(trim($this->uri->_filter_uri($_GET[$this->config->item('directory_trigger')])));
    $segments[] = $this->fetch_directory();
   }

   if (isset($_GET[$this->config->item('controller_trigger')]))
   {
    $this->set_class(trim($this->uri->_filter_uri($_GET[$this->config->item('controller_trigger')])));
    $segments[] = $this->fetch_class();
   }

   if (isset($_GET[$this->config->item('function_trigger')]))
   {
    $this->set_method(trim($this->uri->_filter_uri($_GET[$this->config->item('function_trigger')])));
    $segments[] = $this->fetch_method();
   }
  }

  // Load the routes.php file.
  if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
  {
   include(APPPATH.'config/'.ENVIRONMENT.'/routes.php');
  }
  elseif (is_file(APPPATH.'config/routes.php'))
  {
   include(APPPATH.'config/routes.php');
  }
  
  $this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route;
  unset($route);

  // Set the default controller so we can display it in the event
  // the URI doesn't correlated to a valid controller.
  $this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']);

  // Were there any query string segments?  If so, we'll validate them and bail out since we're done.
  if (count($segments) > 0)
  {
   return $this->_validate_request($segments);
  }

  // Fetch the complete URI string
  $this->uri->_fetch_uri_string();

  // Is there a URI string? If not, the default controller specified in the "routes" file will be shown.
  if ($this->uri->uri_string == '')
  {
   return $this->_set_default_controller();
  }

  // Do we need to remove the URL suffix?
  $this->uri->_remove_url_suffix();

  // Compile the segments into an array
  $this->uri->_explode_segments();

  // Parse any custom routing that may exist
  $this->_parse_routes();

  // Re-index the segment array so that it starts with 1 rather than 0
  $this->uri->_reindex_segments();
 }

 다음글 초보자입니다. default_controller 못 찾... (1)
 이전글 [초보]index.php 제거 질문입니다. (6)

댓글

변종원(웅파) / 2012/09/06 10:29:35 / 추천 0
아파치 재시작하면 몇일동안 에러가 안난다면 서버 리소스나 메모리 누수를 의심해볼 수 있겠네요.

profiler 활성화 시켜서 각 페이지의 메모리 사용량을 체크해보시구요.

리눅스서버라면 top 명령어로 cpu 사용률과 메모리 사용률 체크해보세요.
한대승(불의회상) / 2012/09/06 12:25:47 / 추천 0
에러 발생 지점을 살펴 보니   주로  config  객체 관련 해서 문제가 생기는 군요.
에러메시지만 놓고 보면 config 관련 파일들이 로드 되지 않았거나 접근 불가능 해서 생기는 문제처럼 보이는군요.

몇일 동안 에러가 안난다면..

웅파님 말대로 메모리 누수나 서버 리소스가 의심 되는데요.

에플리케이션 구축 하시면서 파일 작업을 많이 하는지 궁금하네요.
파일 오픈만 하고 닫지 않은 곳이 있는지 확인해 보세요.
빈번한 파일 오픈으로 인한 서버 리소스 부족도 의심이 됩니다.
눈꽃 / 2012/09/06 13:23:34 / 추천 0
답변 너무너무 감사드립니다.

저도 너무 어이가없어서 에러나는 위치 바로위에서 변수값을 채워보기도 하였으나 안되더라구요..

제가 외부모듈같이 사용하는부분에서 fopen을 많이 사용하고있습니다(단순 GET URL호출용)

fopen을 close 해주지않아서 그것때문에 위의 에러가 발생한다는 추측이 맞는것인가요?

close를 넣은후 몇일을 지켜봐야겠네요-_- ㅋ 
변종원(웅파) / 2012/09/06 13:41:12 / 추천 0
눈꽃/ 안 닫으면 당연히 누적되서 메모리 누수가 생깁니다. 어느 시점되면 메모리 full...
이후 에러..