| [ CnUnix ] in KIDS 글 쓴 이(By): flesh (t(-_-t);;) 날 짜 (Date): 2002년 7월 30일 화요일 오후 11시 05분 23초 제 목(Title): Re: 프로그램의 메모리 사용량 증가.. 쿼리 결과치 쓰고 당연히 free()과정이 있어야 할 듯 싶은데요. 결과치라 말씀하시는 것은 ResultSet (in java)이 분명한데, 이런 공간들은 DB call 하고 난 다음에 발생하겠죠? 그럼 malloc() 같은 것으로 잡을게 분명할 것 같습니다. 괜시리 array로 구성했다가 dangling pointer 현상을 만날수도 있고 분명하게, malloc()메커니즘 이용했을 테고, 그렇게 되면 적체됩니다. 메모리. mysql API에서 이런 부분이 있을텐데..... 자바같은 곳에서야 저런걱정안해도 되지만, C에선 문제가 될것 같습니다. 그 ResultSet이란 놈이 아래 같은 놈일 것 같은데... -- This is a type-safe representation of one row of data. It is currently implemented as an array of counted byte strings. (You cannot treat these as null-terminated strings if field values may contain binary data, because such values may contain null bytes internally.) Rows are obtained by calling mysql_fetch_row(). -- fetch_row()는 DB의 row를 그대로 가져오는 역할을 하지요. 여기서 적절한 cast 가 필요하고... (아마 요놈은 적절히 get하는 게 있겠지요.) 그리고 그런 resultset에 대한 release는 다음의 function에 명시되어 있습니다. -- mysql_free_result() Frees memory used by a result set. -- free 안해줘도 된다! 라는 말이 없으면 free()해주는 게 상식일 것 같습니다. 데이터 형 선언해주고 정의를 내렸다고 memory 잡히는 것은 아닐테고, 그러니 천 상 내부적인 logic은 malloc()/free() 일 것 같습니다. -- After you are done with a result set, call mysql_free_result() to free the memory used for it. mysql_free_result() void mysql_free_result(MYSQL_RES *result) Description Frees the memory allocated for a result set by mysql_store_result(), mysql_use_result(), mysql_list_dbs(), etc. When you are done with a result set, you must free the memory it uses by calling mysql_free_result(). Return Values None. -- 역시 관련 내용이 있군요. 조기~ must free 보이시죠? :) 이놈 문제일 수 있을 수도! 너무 쉬운 내용을 일일히 찾아가면서 comment 하느라 길어졌습니다. 개떡같은 코멘트 잘 보시길. :) http://www.mysql.com/documentation/mysql/full/index.html 여기서 참조했습니다. Sincerely yours. - from devil |