Serious memory leak!
Hello. I investigated the memory leak issue. I have such code (modified KitchenSink):
var scrollView = Titanium.UI.createScrollableView({
views:[],
showPagingControl:true,
pagingControlHeight:30,
maxZoomScale:2.0,
currentPage:1,
});
var dir = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory+'/hires');
var files = dir.getDirectoryListing();
for(i=0;i<files.length;i++)
{
var img = Titanium.UI.createImageView({
backgroundImage:'../hires/'+files[i],
width:640,
height:880,
left:0,
top:0,
});
var scroll = Titanium.UI.createScrollView({
contentWidth:320,
contentHeight:440,
minZoomScale:0.5,
});
scroll.add(img);
scrollView.addView(scroll);
}
win.add(scrollView);
So I noticed that every Scroll event free memory decreased by 2-3MB, looks like Titanium creates new view for current focused view and there is NO way to release the memory.
I don't understand why memory consumes when I scroll to new view. All views already loaded in that For cycle.
I have app crash after 7-8 scrolls on my iPhone 3G.
1.3.0 SDK
24 Answers
-
This might help you.
http://shakilspace.blogspot.com/2011/02/appcelerator-titanium-scrollview-swipe.html
:)
-
i can concur with this problem and lots of others on Q/A here too. The memory reduces each time an imageView is adding to the scrollableview (either using backgroundimage or image attribute do not matter).
If you compile/run your project in XCODE/DEBUGGER you can see that garbage collect only occurs only when the memory is almost depleted, at that point the app would be starting to crash. I still haven't found a solution to it yet, but been trying to mess around with TI iphone/class to force a garbage collect…so we'll see.
1.4 is complete a bug kill for me since there're so many problems i've run into.
-
ScrollableView is absolutely useless when adding many objects to every view. I failed to complete my application, it was just 5 small images, 10 labels and 1 background on every view, scrolling was horrible, it just crashed (probably because of memory).
As I know Titanium has its own garbage collector, it definitely needs improvements. You just cannot imagine how many times I faced same memory problem, in fact Titanium is suitable for text-based simple applications, if you want to to something beautiful with custom graphics - just forget it, it will always be slow and may crash on iPhone 3G. -
I think I run into the same problem.
My app loads tons of images and crash very soon and it's always on view.add(something, button, image, anything).
The app freezes.
In simulator, it happens pretty fast.I load a 450x450 png and make a zoom, sometimes it freezes the first time.
On iPhone 4, I can do this a hundred times but it still happen to freeze…
-
This code crashes my iPhone 3G (scrolling from left to right), free memory 2-3 MB
Images in /pages 50-60KB
Images in /hires 300-500KBEven setting back backgroundURL doesn't free up memory
1.4.1 SDK from continious build, iOS 4.0 (emulator and iPhone 3G)
-
Subscribing - bump. FYI try running that on an iPod touch. Even worse. This is a major hurdle for my apps… if there is actually a way to fix the garbage collection it should be a huge priority for Appcelerator.
-
Yeah, waiting for a fix long time. I cannot find the way to fix it on my side, it's inside the SDK. I hope in 1.5 version it will be fixed.
-
Why are you saying Up on a Q/A without asking a question or giving an answer? Nobody is going to have an answer if you don't have a question so what is it? Do you feel there is a memory leak? Have you experienced one? Or are you trying to see if this has been resolved?
-
Up
-
up
-
up
-
I tried running this on my iPhone4 device, iOS SDK 4.0.1 and the latest Titanium continuous build (Jul 30th) from here.
I loaded 10 images, about 2MB in size (2592x1936px) each. I didn't experience any memory leaks or app crashes after fiddling with the scrollable view for a few minutes, zooming in/out etc.
Titanium.Platform.availableMemory
reported these figures:- Application start: 266
- Scrolling through all images once: 235
- Scrolling, zooming for ~1 minute: 235
- Suspending to background/reopening: 236
Here's the exact code I used for testing: http://www.pastie.org/1068804
-
posting so that i can follow this one
-
posting so that i can follow this one
-
same issue here, nothing get ?
-
Has anyone tested this since this commit? (Not sure if it's related)
http://github.com/appcelerator/titanium_mobile/commit/00c73f859f79d422b4c08d05816986a51cb0c999
-
up
-
up
-
up
-
up
-
up
-
up
-
up too!
-
bump