[질문]64비트 환경에서 g++로 프로그래밍중인데 메모리 릭이 있는듯 합니다.

noonti의 이미지

64비트 환경에서 g++로 개발중입니다.
근데 이상하게 new와 delete시 약 3번정도는 메모리가 잘 줄다가 그뒤로는 줄지 않습니다.
물론 더 늘어나지도 않구요..
그리고 malloc과 free의 경우는 잘 동작합니다.
왜 그런걸까요? 32비트 환경의 Fedora 4의 경우는 메모리가 정상적으로 늘었다 줄었다 하는데
왜 64비트의 CentOS환경에서는 약 3번은 정상적으로 줄다가 그뒤로 메모리가 줄어들지 않는걸까요?
아래는 제가 샘플로 짠 코드입니다.
혹 아시는 분 계시면 조언 부탁드립니다.
---------------------------------
#include
#include
#include
typedef struct tagTestREC
{
char * szTemp;

}TestREC;

class TestREC
{

public:
TestREC()
{
}
~TestREC()
{
}
char * szTemp;


};
int main()
{
char szKeyIn[255];
TestREC * pTemp[5000];
char * szTemp[5000];
int nSize=100;
int i,j;
printf("start....any key..\n");
fgets(szKeyIn,255,stdin);

while(1)
{
printf("start....any key..\n");
for(i=0;i {

pTemp[i] = new TestREC;
pTemp[i]->szTemp = (char*)malloc(1024*1024*sizeof(char));
memset(pTemp[i]->szTemp,1,1024*1024);
printf("[%d]address=%x\n",i,pTemp[i]);

}
printf("delete....any key..\n");
fgets(szKeyIn,255,stdin);
for(i=0;i {

free(pTemp[i]->szTemp);
delete pTemp[i];

}
fgets(szKeyIn,255,stdin);
}
return 1;
}

poplinux의 이미지

혹시 메모리 크기는 free 명령어로 보신건가요?

free 메모리가 줄어든 만큼 cache 메모리가 늘어 난 상태라면 걱정 안 하셔도 됩니다.

========================
조직 : E.L.D(Embedded Linux Developer/Designer)
블로그 : poplinux@tistory.com
카페 : cafe.naver.com/poplinux

임베디드 리눅스 관련 프리렌서 지향

noonti의 이미지

답변 감사합니다.
그런데 free 명령어로 확인해보면 cached는 변화가 없습니다.
cached의 값이 늘어나지 않습니다.
우찌 된 일일까요...?ㅠㅠ

kgykingdom의 이미지

valgrind 한번 사용해 보세요.. ^^;;

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.