3,832 questions
1
vote
2
answers
72
views
Why defining string within a function scope allocates it on heap instead of a stack? [duplicate]
According this awesome article there is an interesting case with two given examples:
A:
B:
And there is an explanation for A:
Unfortunately you have not taken into account that such Strings will ...
0
votes
0
answers
51
views
Calling ARC code from non-ARC code causing EXC_BAD_ACCESS when autorelease pool drains
void test(void) {
@autoreleasepool {
NSDictionary *dict = copyDict();
NSLog(@"%lu", [dict retainCount]);
[dict release];
}
}
int main (int argc, const char * ...
1
vote
1
answer
119
views
How do I use Arc with interior mutability over slices?
MRE:
use std::sync::Arc;
use std::thread;
fn main() {
let arr1 = Arc::new(vec![10; 100]);
let arr2 = Arc::new(vec![20; 100]);
let arr3 = Arc::new(vec![00; 100]); // Going to need interior ...
0
votes
0
answers
56
views
NSObject proxy with weak delegate crashes with NSInvalidArgumentException unrecognized selector
I'm debugging a library that implements a UIScrollViewDelegate proxy (essentially) like:
class ScrollViewDelegateProxy: NSObject, UIScrollViewDelegate {
private weak var realDelegate: ...
2
votes
1
answer
69
views
Reference counting an uninitialized object
I have some Objective C code compiled with ARC:
void func(void) {
NSString *string;
// Do some stuff. Maybe return early.
string = @"initialized";
// Other stuff.
}
How ...
2
votes
1
answer
89
views
Arc: how to enable audio player for my own website?
I'm trying to enable the Arc browser audio player on a webpage of mine.
I cannot find any documentation from Arc targeted to developers though, so I tried by using what works for Google Chrome, but it ...
1
vote
2
answers
115
views
Should 'self' be explicitly specified in closure with weak reference to self in capture list?
DispatchQueue.main.async {
view.setNeedsLayout()
}
With above code we get expected error: Implicit use of 'self' in closure; use 'self.' to make capture semantics explicit.
It's known that the ...
0
votes
0
answers
36
views
ARC and the release of custom objects passed into async network methods
In my app I’m running into a problem leaking custom objects passed into a chain of methods that store HTML files into a custom object. Where each method finds a local copy of a file, the file is read ...
0
votes
2
answers
96
views
mutate dynamically sized vec in parallel
I'm trying to mutate a dynamically sized (i.e. under certain conditions, new values are pushed, and pop() gets called in every iteration) Vec in parallel. Am I doing anything wrong in this working ...
0
votes
0
answers
57
views
Deallocation for NSTextView in Objective-C
I am learning to create a Cocoa application on Mac OS and have run into an issue with memory I don't quite understand. From what I've read with non-ARC is that you should be releasing anything you've ...
0
votes
0
answers
27
views
Instantiating ONNX Session and Environment and overcoming borrowing error without having to use unsafe pointers [duplicate]
I have been trying to instantiate an ONNX runtime environment and session within a struct that can also contain all of the public methods I need. I have a working solution, however this requires the ...
0
votes
1
answer
69
views
Fill a matrix in parallel - how to convert `Vec<Arc<Mutex<Vec<_>>>>` to Vec<Vec<_>>`
I'm learning Rust and just finished the Fearless Concurrency chapter in the Rust book, so am trying to fill up the rows of a matrix in parallel.
My matrix is large, so I send a chunk of rows to each ...
1
vote
1
answer
241
views
How does the NSWindow isReleasedWhenClosed property work when using ARC?
In Objective-C with ARC or Swift (which always uses ARC), what difference does it make whether isReleasedWhenClosed is true or not? Won't a window be kept alive as long as my code has strong ...
0
votes
1
answer
375
views
Acquiring an access token using REST API on a ARC Connected VM
I'm wanting to connect a On-Prem VM to Azure KeyVault. I have installed the Azure Arc Agent successfully and can see the VM under ARC Machines in Azure.
However when I go to request the API token as ...
1
vote
1
answer
202
views
Is there a sound way to convert/transmute from Arc<String> to Arc<Vec<u8>>
String and Vec<u8> have the same memory layout, although this is not guaranteed.
String also has an into_bytes method returning a Vec<u8>.
Is there a sound way to convert from an Arc<...