Shinnara's Blog
Talking with Shinnara :: NaraTalk.com


Nokia 의 N95 에 들어갈 이미지 뷰어를 Midlet 으로 만드는데 이상하게 N95 에서 찍은 사진을 로드하게 되면 Unhandled Exception 을 내며 죽는 것입니다. 네트워크를 통해 받는 다른 이미지들은 제대로 보여지는데, N95로 찍은 사진만 그런 문제가 발생하길래, N95 가 Jpeg 를 만들어 낼  때, 약간의 문제가 있지않은가하는 생각을 했었는데,오늘 구글 검색을 통해본 결과 OutOfMemory 에 의한 문제로 밝혀졌네요.

http://discussion.forum.nokia.com/forum/showthread.php?t=108918

위의 글을 보면, 동일한 Exception 때문에 고민한 흔적이 역력하다. J2ME 개발을 꽤 했다고 생각했는데 메모리때문일거라는 생각을 못하다니 창피한 일이 아닐 수 없습니다.

참고로,Java VM 의 memory 크기를 알고 싶은 경우 다음과 같은 메소드를 활용하면 됩니다.

java.lang
Class Runtime


freeMemory

public long freeMemory()
Returns the amount of free memory in the system. Calling the gc method may result in increasing the value returned by freeMemory.
Returns:
an approximation to the total amount of memory currently available for future allocated objects, measured in bytes.

totalMemory

public long totalMemory()
Returns the total amount of memory in the Java Virtual Machine. The value returned by this method may vary over time, depending on the host environment.

Note that the amount of memory required to hold an object of any given type may be implementation-dependent.

Returns:
the total amount of memory currently available for current and future objects, measured in bytes.

Runtime class 에 totalMemory() 와 freeMemory() 가 존재하므로 이를 활용하여 메모리를 많이 사용하는 어플리케이션의 작동 상태를 조절할 수 있겠지요? 저의 경우는 반복적인 이미지 로드를 막기위해 프로그램에서 캐싱을 구현해놨었는데, 이부분을 메모리 사이즈와 관련해서 조절해봐야겠네요.


0 Trackback, 0 Comment

TRACKBACK :: http://naratalk.com/trackback/169 관련글 쓰기

댓글을 달아 주세요

1  ... 153 154 155 156 157 158 159 160 161  ... 264 
다...... (264)
Computer/Programming (106)
Links (14)
책 읽는 즐거움 (7)
끄적임 (66)
즐거운 과학 나라 (7)
일본 (5)
Study (4)