My app takes the NSData of movie objects and sends it over a network. The problem is, if the video is large enough, I'm worried my app will crash because of having so much data in memory. Is there a way to check the limits of the iPhone being used, so I can stop it transferring videos larger than that?
我的应用程序获取电影对象的NSData并通过网络发送它。问题是,如果视频足够大,我担心我的应用程序会崩溃,因为内存中有这么多数据。有没有办法检查正在使用的iPhone的限制,所以我可以阻止它传输大于这个的视频?
3 个解决方案
#1
2
Your application will receive a memory warning when it is using too much memory. That is your only way of knowing. A view controller will get its didReceiveMemoryWarning
method called. A UIApplicationDidReceiveMemoryWarningNotification
event will also be raised.
当您的应用程序使用太多内存时,它将收到内存警告。这是你唯一的认识方式。视图控制器将调用其didReceiveMemoryWarning方法。还将引发UIApplicationDidReceiveMemoryWarningNotification事件。
#2
1
I dont think its right define a limit on the basis of memory available in the device. I would suggest you to upload file from disk. ASIHTTP has provision to stream file from disk. This will solve your memory problem.
我认为它没有根据设备中可用的内存定义限制。我建议你从磁盘上传文件。 ASIHTTP提供从磁盘流式传输文件。这将解决您的记忆问题。
#3
0
Even if you find out the amount of memory available on the current device, the system will start killing apps long before you allocate even a half of that amount. Can’t you simply choose a sensible safe block size and send the video in chunks?
即使您发现当前设备上可用的内存量,系统也会在您分配甚至一半的数量之前很久就开始查杀应用程序。难道你不能简单地选择合理的安全块大小并以块的形式发送视频吗?
#1
2
Your application will receive a memory warning when it is using too much memory. That is your only way of knowing. A view controller will get its didReceiveMemoryWarning
method called. A UIApplicationDidReceiveMemoryWarningNotification
event will also be raised.
当您的应用程序使用太多内存时,它将收到内存警告。这是你唯一的认识方式。视图控制器将调用其didReceiveMemoryWarning方法。还将引发UIApplicationDidReceiveMemoryWarningNotification事件。
#2
1
I dont think its right define a limit on the basis of memory available in the device. I would suggest you to upload file from disk. ASIHTTP has provision to stream file from disk. This will solve your memory problem.
我认为它没有根据设备中可用的内存定义限制。我建议你从磁盘上传文件。 ASIHTTP提供从磁盘流式传输文件。这将解决您的记忆问题。
#3
0
Even if you find out the amount of memory available on the current device, the system will start killing apps long before you allocate even a half of that amount. Can’t you simply choose a sensible safe block size and send the video in chunks?
即使您发现当前设备上可用的内存量,系统也会在您分配甚至一半的数量之前很久就开始查杀应用程序。难道你不能简单地选择合理的安全块大小并以块的形式发送视频吗?