매번 아무 생각 없이 써온 함수인데, 최근에서야 문제점을 알았다.

MSDN 을 보니 어느샌가 아래와 같은 것이 추가 되어 있었다

GlobalMemoryStatus Function

[GlobalMemoryStatus can return incorrect information. Use the GlobalMemoryStatusEx function instead. ]

Retrieves information about the system's current usage of both physical and virtual memory.

잘못된 정보를 리턴할 수 있으니 Ex 함수를 사용하라는 것이었다.

그래서 다시 아래로 내려가 보았더니,

Remarks

On computers with more than 4 GB of memory, the GlobalMemoryStatus function can return incorrect information, reporting a value of –1 to indicate an overflow. For this reason, applications should use the GlobalMemoryStatusEx function instead.

On Intel x86 computers with more than 2 GB and less than 4 GB of memory, the GlobalMemoryStatus function will always return 2 GB in the dwTotalPhys member of the MEMORYSTATUS structure. Similarly, if the total available memory is between 2 and 4 GB, the dwAvailPhys member of the MEMORYSTATUS structure will be rounded down to 2 GB. If the executable is linked using the /LARGEADDRESSAWARE linker option, then the GlobalMemoryStatus function will return the correct amount of physical memory in both members.

The information returned by the GlobalMemoryStatus function is volatile. There is no guarantee that two sequential calls to this function will return the same information.

라고 되어 있었다.

4GB 이상일때도 문제가 있고, 2GB 에서 4GB 사이인 경우에는 항상 2GB 로 리턴한다는 문제였다. /LARGEADDRESSAWARE 로 실행되면 잘 동작한다지만 항상 그렇게 실행하도록 프로그램을 작성하는 것은 옳지못한 방법이다.

그래서 결과적으로 메모리 정보를 얻어오는 부분을 수정하기로 했다. Ex 로...

우리는 하루에도 수백번씩 웹 페이지를 열고 닫습니다. 어느새 생활에 일부가 되어버린 웹 서핑!

하지만, 혹시 광고에 시달리고 있지는 않습니까?

특히, 대형 포탈들의 광고는 점점 도를 넘어, 이제는 잠깐 마우스만 잘못 위치해도 화면 전체를 차지하는 광고가 뜨기도 합니다.

서핑을 하면서 갑자기 큰 소리가 나거나 어디서 들리는 지 모르는 소리들이 났을 때, 이것이 광고에서 나오는 것이었던 적은 없으셨나요?

이제 이 모든 문제를 손쉽게 해결할 수 있습니다.

파일 최적화에서 '내 컴퓨터' 를 선택하였을 경우, 정상적으로 검색을 못하고 종료되지 않는 버그가 있었습니다.

현재 수정되어 3.2 버전에 반영될 예정입니다.

알려주신분 : 홍의표 (http://www.cyworld.com/koky)

+ Recent posts