通过小字节数组我的意思是从10长度最多为30个字节的阵列.
通过商店我的意思是将它们存储在RAM中,而不是序列化并持久保存到文件系统.
系统macOS 10.12.6,Oracle jdk1.8.0_141 64位,JVM args -Xmx1g
示例:
预期的行为new byte[200 * 1024 * 1024]是≈200mb的堆空间
public static final int TARGET_SIZE = 200 * 1024 * 1024;
public static void main(String[] args) throws InterruptedException {
byte[] arr = new byte[TARGET_SIZE];
System.gc();
System.out.println("Array size: " + arr.length);
System.out.println("HeapSize: " + Runtime.getRuntime().totalMemory());
Thread.sleep(60000);
}
Run Code Online (Sandbox Code Playgroud)
public static final int TARGET_SIZE = 200 * 1024 * 1024;
public static void main(String[] args) throws InterruptedException {
final …Run Code Online (Sandbox Code Playgroud) 通过提供后台队列,可以在后台线程上回调从任何线程进行的查询,如下例所示:
Run Code Online (Sandbox Code Playgroud)service.delegateQueue = [[NSOperationQueue alloc] init];指定委托队列时,不需要在执行查询的线程上运行运行循环.
但是,它不起作用.处理程序仍在主线程上执行.
如何告诉Google Drive服务在后台线程上执行处理程序?
Podfile:
pod 'GTMOAuth2'
pod 'GoogleAPIClient/Drive'
Run Code Online (Sandbox Code Playgroud)
申请中的某个地方:
#import "GTLDrive.h"
#import "GTMOAuth2Authentication.h"
...
- (void) applicationDidFinishLaunching:(NSNotification *) aNotification {
service = [[GTLServiceDrive alloc] init];
service.retryEnabled = YES;
service.authorizer = _authorizer //from GTMOAuth2WindowController
service.delegateQueue = [[NSOperationQueue alloc] init];
GTLDriveFile * tempadFolder = [GTLDriveFile object];
folder.name = @"folder-name";
folder.mimeType = @"application/vnd.google-apps.folder";
GTLQueryDrive * query = [GTLQueryDrive queryForFilesCreateWithObject: folder uploadParameters: nil];
[service executeQuery: query completionHandler:
^(GTLServiceTicket * ticket, …Run Code Online (Sandbox Code Playgroud)