타이타늄 Out Of Memory 에러 ㅠㅠ

Android SDK : 3.1.3
Titanium Studio : 3.2.3

Ti.Media.showCamera
	({
		success:function(e)
		{
			if(e.mediaType == Ti.Media.MEDIA_TYPE_PHOTO)
			{
				
				$.imageView.image =e.media;
				thumImage = Titanium.UI.createImageView
				({
					width: '2%',
					height: '60%',
					borderRadius :'8',
					left: '0.2%',
					 borderColor: '#37b2ab',
					 borderWidth :'1',
					 top: '10%',
					 image : e.media
				});
				
				
			       $.insert_scrollList.add(thumImage);
						
				thumArray.push(thumImage);
				thumImage.addEventListener('click', function(e)
				{
					$.imageView.image = e.source.image;
				}) ;
				
				var photoDB = Ti.Database.open('testDB');
				
			    try
				{
					
					photoDB.execute("INSERT INTO PICTURE ( MNG_NO, FILE,SHOOTING_DT) VALUES (?,?,?)" ,now , $.imageView.image.nativePath ,inTime);
				}
				catch(che)
				{
					alert('photo e ' + che);
				}
				finally
				{
					photoDB.close();
				}
			}
		},
		error:function(e)
		{
			alert("There was an error");
		},
		cancel:function(e)
		{
			alert("The event was cancelled");
		},
		allowEditing:true,
		saveToPhotoGallery:false,
		mediaTypes:[Ti.Media.MEDIA_TYPE_PHOTO, Ti.Media.MEDIA_TYPE_VIDEO],
		videoQuality:Ti.Media.QUALITY_LOW
	});

이런식으로 이미지를 스크롤뷰에 넣고 click 이벤트를 걸어주었습니다.
근데 이미지를 클릭하면 Out Of Memory 에러가 발생합니다 ㅠㅠ
혹시 도움이 될만한 정보 있으시면 공유 좀 부탁드립니다 ㅠㅠㅠ
이 정도 설명이면 가능할런지요…

[ERROR][dalvikvm-heap( 9506)] Out of memory on a 19468816-byte allocation.
[ERROR][TiDrawableReference( 9506)] (pool-3-thread-1) [6547,106189] Unable to load bitmap. Not enough memory: null
[ERROR][TiDrawableReference( 9506)] java.lang.OutOfMemoryError
[ERROR][TiDrawableReference( 9506)] at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
[ERROR][TiDrawableReference( 9506)] at android.graphics.BitmapFactory.decodeStreamInternal(BitmapFactory.java:613)
[ERROR][TiDrawableReference( 9506)] at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:589)
[ERROR][TiDrawableReference( 9506)] at org.appcelerator.titanium.view.TiDrawableReference.getBitmap(TiDrawableReference.java:324)
[ERROR][TiDrawableReference( 9506)] at org.appcelerator.titanium.util.TiLoadImageManager$LoadImageJob.run(TiLoadImageManager.java:128)
[ERROR][TiDrawableReference( 9506)] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
[ERROR][TiDrawableReference( 9506)] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
[ERROR][TiDrawableReference( 9506)] at java.lang.Thread.run(Thread.java:841)

어떻게 구현한지에 대한 코드나 설명없이 에러메시지만 가지고 문제를 해결하기에는 어려움이 있어요.
아래 글을 참고하여 보다 자세한 정보를 알려주시면 다른 분들이 도움을 더 쉽게 드릴 수 있습니다.

올려주신 코드를 봤을 때 두가지 이슈를 생각해볼 수 있는데요.

  1. 이미지를 리사이즈하고 파일로 다루기
    이미지를 한꺼번에 많이 다룰 경우 계속 메모리를 통해 다루기 보다 file을 통해 저장해 두고 사용하는 것도 하나의 방법입니다. 또한 실제 카메라에서 넘어온 화질은 상당히 고화질입니다. 이 고화질을 직접 다룰 이유가 없다면 e.media의 이미지를 resize하고나서 다루는 것을 추천합니다.
    이미지 리사이즈나 jpg등으로 압축할때 저는 ti.imagefactory 모듈을 사용합니다.

  2. showCamera의 success안에서의 생성된 클로져로 인한 메모리 릭
    코드를 보면 success안에서 addEventListener를 아래와 같이 걸고 있습니다. 이때 success의 핸들러로 넘어온 event가 (success:function(e)의 e) 계속 메모리에 남아있게 됩니다. 용량이큰 blob의 refrence count를 늘릴 필요는 없겠죠. 더더욱 showcamera에서 넘어온 blob은 원본이미지로 무지 크니까요. eventlisenter의 선언 위치를 변경하거나 e = null 처럼 강제로 reference count를 줄여주세요.

참고 문서

그런데 @xornjs1234 님 한글 이름이 강렬하네요.^^

감사합니다 ㅠㅠㅠㅠㅠㅠ
이미지 리사이징하는 방식으로 해결했습니다.