首页 \ 问答 \ 我的应用程序如何在Android 4.0中分配更多堆内存?(How can my app allocate more heap memory in Android 4.0? (Not enough memory for my app) [closed])

我的应用程序如何在Android 4.0中分配更多堆内存?(How can my app allocate more heap memory in Android 4.0? (Not enough memory for my app) [closed])

我对我的应用程序不满意。 我正在为专用条码扫描器基于Android的设备开发应用程序。 它就像一部旧手机(CPU Cortex-A8 OMAP 1Ghz,512MB RAM)和Android 4.0。 我不能根系统,也不能更新它,我已经和制造商谈过了。

问题是无法完成简单(JSON)登录。 它试图分配更多的内存,但它不能。

条形码设备android,7分钟后

这是同一个网络中相同的活动和相同的进程,但是在LG G2中(按预期方式进行登录和同步需要大约5秒)

同样的活动,在LG G2上

在条形码扫描仪设备中,我删除或休眠了所有应用程序,我已经安装了Zend Launcher(内存占用很少),但我现在已经没有想法了。 我已经尝试过android:largeHeap on manifest,但没有成功。

有人对我有想法吗? 提前致谢

PS:该应用程序必须在该条形码扫描仪中运行,在LG G2上工作仅用于测试和比较目的。

编辑:我不关心后台其他应用程序,因为这个设备基本上将使用这个应用程序,没有别的。


I'm desesperate with my app. I'm developing an app for a dedicated barcode scanner Android based device. It's like an old phone (CPU Cortex-A8 OMAP 1Ghz, 512MB RAM), with Android 4.0. I can't root the system, nor update it, i've talked with the manufacturer.

The problem is that can't finish a simple (JSON) login. It tries to allocate more memory, but it can't.

Barcode device android, after 7 mins

Here is the same activity and the same process in the same network, but in an LG G2 (it tooks about 5s doing the login and the sync, as expected)

Same activity, on LG G2

In the barcode scanner device, I removed or hibernated ALL of the apps I can, I've installed Zend Launcher (which has a very little memory footprint), but I'm out of ideas now. I've tried android:largeHeap on manifest, without success.

Somebody has an idea for me? Thanks in advance

PS: The app must run in that barcode scanner, working on LG G2 is only for test and comparative purposes.

EDIT: I don't care about other apps in background, because this device will basically use this app, and nothing else.


原文:https://stackoverflow.com/questions/30231948
更新时间:2022-10-22 21:10

最满意答案

AES可能比它的价值更麻烦。 就像我尊重Jeff LaMarche一样,这种实现并不好。 这对于这个目的来说已经足够了,但除非你理解它的正确性和错误,否则不能在我看来复制它。 我通过使用CommonCrypto的AES正确加密,详细讨论了这个问题,并包括如何正确地进行AES; 但是你可能不想在这里正确地做正确的AES麻烦,如果你做的话它也不会给你带来太大帮助。

我的建议是一个简单的校验和哈希:

- (NSUInteger)checksumForScore:(NSUInteger)score player:(GKPlayer *)player {
  NSString *string = [NSString stringWithFormat:@"%d%@%@", score, [player playerID], kLongRandomPassword];
  return [string hash];
}

然后,您将校验和与分数一起存储。 你验证它像:

- (BOOL)isValidChecksum:(NSUInteger)checksum forScore:(NSUInteger)score player:(GKPlayer *)player {
  return (checksum == [checksumForScore:score player:player]);
}

我在这里使用了GKPlayer playerID来挑选一些易于使用的东西,但对于设备所有者在玩游戏时更改并非易事。 这样做会使重播攻击变得困难。 我不能把我朋友的plist条目与我的plist的超高分复制。 当用户更换设备或恢复此设备时,它也非常持久。 如果你没有使用GameKit,首先,你应该:D和第二,你必须弄清楚你是否还想要使用其他键。 如果您让用户在某个时刻输入,那么“用户句柄”也可以。 任何对用户来说都是独一无二的东西,他不会只是复制他的朋友。

Keychain作为一种混淆技术很有意思。 甚至合法地阅读也是一种皇家的痛苦,因此官方SDK提供了自己的混淆:DI怀疑它值得麻烦,但它是一个“隐藏”少量数据的好地方。

NSCoding甚至都不是混淆。 任何打算打开plist的人都可以在不到一分钟的时间内读写NSCoding 。 将此转换为NSData 。 将其存储在SQLite或Core Data中也是如此。

@CocoaFu对NSDataWritingFileProtectionComplete的建议很聪明,但我怀疑它会对越狱设备产生任何实际影响。 一旦设备解锁,操作系统将为您解密任何文件,因此对于知道设备PIN的人来说,这根本不是障碍。


AES is probably more trouble than it's worth here. Much as I respect Jeff LaMarche, this implementation is not good. It's adequate for this purpose, but it's not something to copy around in my opinion unless you understand what's right and what's wrong with it. I talk about this at length in Properly encrypting with AES with CommonCrypto and include how to do AES correctly; but you probably don't want the hassle of doing AES correctly here, and it wouldn't buy you much if you did.

My recommendation is a simple checksum hash:

- (NSUInteger)checksumForScore:(NSUInteger)score player:(GKPlayer *)player {
  NSString *string = [NSString stringWithFormat:@"%d%@%@", score, [player playerID], kLongRandomPassword];
  return [string hash];
}

You then store the checksum along with the score. You validate it like:

- (BOOL)isValidChecksum:(NSUInteger)checksum forScore:(NSUInteger)score player:(GKPlayer *)player {
  return (checksum == [checksumForScore:score player:player]);
}

I've used GKPlayer playerID here to pick something that's easy for you to use, but not trivial for the device owner to change while playing. Doing it this way makes replay attack hard. I can't just copy my friend's plist entry with it's super-highscore to my plist. It's also nicely persistent when the user changes devices or restores this device. If you're not using GameKit, first, you probably should :D and second, you'll have to figure out if there's some other key you want to use. A "user handle" would be fine too if you have the user enter that at some point. Anything that's unique-enough to the user that he wouldn't just copy his friend's.

Keychain is interesting as an obfuscation technique. It's a royal pain to read even legitimately, so the official SDK provides its own obfuscation :D I doubt it's worth the trouble, but it is a decent place to "hide" small amounts of data.

NSCoding isn't even obfuscation. Anyone who's going to bother to open up the plist can read and write NSCoding in less than a minute. Same for turning this into an NSData. Same for storing it in SQLite or Core Data.

@CocoaFu's suggestion of NSDataWritingFileProtectionComplete is clever, but I doubt it will have any real impact on a jailbroken device. Once the device is unlocked, the OS will will decrypt any file for you, so it's no barrier at all to someone who knows the device's PIN.

相关问答

更多
  • 谢谢你没有回复:P 但我最终最终解决了它。 这就是我所做的,也许它会帮助其他任何人。 我所要做的就是创建一个自定义磁盘缓存和自定义下载器。 在自定义磁盘缓存类中,在UIL将字节流写入文件的方法中,我加密了字节流。 在自定义下载程序中,我重写了从文件中获取字节流并对其进行解密的方法。 Thanks for not replying :P But I did eventually end up solving it. And here is what I did, maybe It will help anyo ...
  • 您不需要virtualFile 。 您已经在imageStringBugger拥有了图像数据。 从而: with file('filename_to_save_to.png', 'wb') as f: f.write(imageStringBuffer) 足够。 def handle_uploaded_file(f): with open('imgepath', 'wb+') as destination: for chunk in f.chunks(): ...
  • 如果你对选择有约束力,用户也可以篡改这些值。 只需验证隐藏字段就像使用其他输入一样。 不要担心漂亮的反馈,如果值超出范围,就抛出异常。 如果有人试图摆弄你的表格,谁会在乎他是否有丑陋的错误。 我想更简洁地回答你的问题:你不能防止篡改客户端,你所能做的只是验证 - 服务器端 If you were binding to the select a user could tamper with those values too. Just validate the hidden field like you wo ...
  • 要将发送到磁盘的所有内容重定向到磁盘,只需使用System :: setOutput函数并传入FMOD_OUTPUTTYPE_WAVWRITER值。 确保在调用System :: init之前调用此函数,完成调用System :: release后,可执行文件旁边会出现一个wav文件。 您还可以通过System :: init extradriverdata参数传递完整路径来指定输出wav文件的名称和位置。 To redirect everything that would go to the speake ...
  • 无论是通过$_GET查询篡改还是通过基于cURL的查询,您都无法阻止用户进行篡改,这就是它的方式,但是您可以通过使用加密或令牌使用户更难以篡改。 假设您有任何类型的用户输入,它可能会被篡改。 快速说明,我不是任何想象力的密码学专家,所以不要把它作为佳能。 你应该根据自己的需要做更多的研究。 如果您需要保留已登录用户的数据,您应该考虑使用会话而不是通过$_GET查询传递。 双向数据加密: 根据您的需要, openssl可能是一种选择。 如果我想传输数据但是不一定希望最终用户以纯文本形式查看,我会使用这种类型的 ...
  • AES可能比它的价值更麻烦。 就像我尊重Jeff LaMarche一样,这种实现并不好。 这对于这个目的来说已经足够了,但除非你理解它的正确性和错误,否则不能在我看来复制它。 我通过使用CommonCrypto的AES正确加密,详细讨论了这个问题,并包括如何正确地进行AES; 但是你可能不想在这里正确地做正确的AES麻烦,如果你做的话它也不会给你带来太大帮助。 我的建议是一个简单的校验和哈希: - (NSUInteger)checksumForScore:(NSUInteger)score player:( ...
  • 一般的解决方案很简单: myvar = ind{1}; save myfilename myvar; load myfilename; 如果未指定变量,则save / load处理工作区/文件中的所有变量。 您可以保存/加载多个特定变量: save myfilename; save myfilename myvar1; save myfilename myvar2; save myfilename myvar1 myvar2; load myfilename; load myfilename myva ...
  • 除了POST和Post / Redirect /获取建议..一般情况下: 永远不要相信您在HTTP请求中收到的任何信息(包括GET参数,POSTed数据,Cookie和HTTP标头)。 始终确保用户有权对相关数据对象执行每个操作,并且在接受和处理数据之前,始终在服务器端验证数据是否合理。 In addition to the POST and Post/Redirect/Get advice.. In general: Never ever trust any of the information you ...
  • 在JSF中,如果使用required="true"明确设置了这些字段,则应该已经不可能了。 如果省略这个和/或替换自定义验证器或者在bean操作方法中进行验证,那么机器人确实能够篡改表单。 因此,要解决此问题,请将显式required="true"添加到具有硬服务器端值的必填字段(因此不需要例如required="#{not empty param.foo}"或者客户端/机器人可以控制param.foo )。 由于视图状态存储在服务器端,因此webbot无法显示/修改状态。 至少,这就是理论。 或者它必须是 ...
  • 它看起来好像您在带Retina显示器的Mac上运行您的代码。 如果是这种情况,答案就在这里: 如何保存JavaFX Canvas的高DPI快照 It looks as if you are running your code on a Mac with Retina display. If that is the case, the answer is here: How to save a high DPI snapshot of a JavaFX Canvas

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。