memory-management

After migrating from SDK 28 to SDK 29 in Android my app crashed and facing : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), error in Android studio 3.4.1

给你一囗甜甜゛ 提交于 2021-01-27 17:53:09
问题 Iam facing the issue only in OnePlus, Samsung , Poco F1 with Android OS version 10. It's working in pixel devices with Android 10. Please find the error logs below Build fingerprint: 'Xiaomi/beryllium/beryllium:10/QKQ1.190828.002/V11.0.6.0.QEJMIXM:user/release-keys' Revision: '0' ABI: 'arm64' Timestamp: 2020-03-16 18:10:34+0530 pid: 2594, tid: 2737, name: JavaBridge >>> com.mymobile<<< uid: 10362 signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x7188e089db Cause: execute-only (no-read)

When a unique_ptr is deallocated?

那年仲夏 提交于 2021-01-27 16:11:58
问题 In this code: void f(std::unique_ptr<int> q) { } void g() { std::unique_ptr<int> p{new int{42}}; f(std::move(p)); } At which line p is deallocated? I'd say at the exit of the f function because it was moved there using std::move, but I'm not sure nor confident about this answer. 回答1: At which line p is deallocated? At the end of the scope where it was declared i.e the function g in this case. That is when objects with automatic storage are destroyed, and their memory deallocated. The integer

LInux Kernel API to find the vma corresponds to a virtual address

三世轮回 提交于 2021-01-27 10:29:25
问题 Is there any Kernel API to find the VMA corresponds to virtual address? Example : if a have an address 0x13000 i need some function like below struct vm_area_struct *vma = vma_corresponds_to (0x13000,task); 回答1: You're looking for find_vma in linux/mm.h . /* Look up the first VMA which satisfies addr < vm_end, NULL if none. */ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long addr); This should do the trick: struct vm_area_struct *vma = find_vma(task->mm, 0x13000);

Correct use of free() when deallocating a 2d matrix in c

十年热恋 提交于 2021-01-27 09:10:58
问题 I'm just starting to learn coding in c, and I have a few questions regarding 2d matrices in combination with the free() command. I know that you first need to create an array with pointer, pointing to the different columns of the matrix: double **array = (double **)malloc(5*sizeof(double *)); for(int n = 0; n<5; n++){ array[n] = (double *) malloc(6*sizeof(double)); I know that the correct way to then deallocate this matrix is to first deallocate the individual rows and then the array pointer

Safely moving a C++ object

て烟熏妆下的殇ゞ 提交于 2021-01-27 07:10:16
问题 I’ve heard some words of warning against shipping an object to another memory location via memcpy , but I don’t know the specific reasons. Unless its contained members do tricky things that depend on memory location, this should be perfectly safe … or not? EDIT: The contemplated use case is a data structure like a vector , which stores objects (not pointers to objects) in a continuous chunk of memory (i.e. an array). To insert a new object at the n -th position, all objects starting at

Dataset does not fit in memory

放肆的年华 提交于 2021-01-27 07:08:45
问题 I have an MNIST like dataset that does not fit in memory, (process memory, not gpu memory). My dataset is 4GB. This is not a TFLearn issue. As far as I know model.fit requires an array for x and y . TFLearn example: model.fit(x, y, n_epoch=10, validation_set=(val_x, val_y)) I was wondering is there's a way where we can pass a "batch iterator", instead of an array. Basically for each batch I would load the necessary data from disk. This way I would not run into process memory overflow errors.

Allocated array already zeroed

六月ゝ 毕业季﹏ 提交于 2021-01-27 06:47:44
问题 In C++11 when I allocate a dynamic array using T *array = new T[n]; it's already zeroed (using gcc 4.7.2, Ubuntu 12.10 64bit). Is this forced by the C++11 specification? How can one allocate an array without zeroing its items? This should be probably a little bit faster. Edit: I've checked that for T = int . gcc cxx-flags : -std=gnu++11 -O3 -ffast-math -fno-rtti 回答1: § 5.3.4 If the new-initializer is omitted, the object is default-initialized (8.5); if no initialization is performed, the

Allocated array already zeroed

非 Y 不嫁゛ 提交于 2021-01-27 06:47:01
问题 In C++11 when I allocate a dynamic array using T *array = new T[n]; it's already zeroed (using gcc 4.7.2, Ubuntu 12.10 64bit). Is this forced by the C++11 specification? How can one allocate an array without zeroing its items? This should be probably a little bit faster. Edit: I've checked that for T = int . gcc cxx-flags : -std=gnu++11 -O3 -ffast-math -fno-rtti 回答1: § 5.3.4 If the new-initializer is omitted, the object is default-initialized (8.5); if no initialization is performed, the

ARC: __bridge versus __bridge_retained using contextInfo test case

有些话、适合烂在心里 提交于 2021-01-27 05:54:27
问题 Consider this ARC code: - (void)main { NSString *s = [[NSString alloc] initWithString:@"s"]; [NSApp beginSheet:sheet modalForWindow:window modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:context:) contextInfo:(__bridge void *)s ]; } - (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode context:(void *)context { NSString *s = (__bridge_transfer NSString *)context; } Question: on line 7, should __bridge be used, or __bridge_retained , or does it not matter,

ARC: __bridge versus __bridge_retained using contextInfo test case

和自甴很熟 提交于 2021-01-27 05:54:24
问题 Consider this ARC code: - (void)main { NSString *s = [[NSString alloc] initWithString:@"s"]; [NSApp beginSheet:sheet modalForWindow:window modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:context:) contextInfo:(__bridge void *)s ]; } - (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode context:(void *)context { NSString *s = (__bridge_transfer NSString *)context; } Question: on line 7, should __bridge be used, or __bridge_retained , or does it not matter,