memory-management

MemoryManagement with UINavigationController

那年仲夏 提交于 2019-12-25 03:04:27
问题 I have an "issue" with my NavigationController. Actually it seems to me, that this behavior seems to be intended. My App uses a SplitViewController, using a TableViewController for the MasterView and a NavigationController for the DetailView. I have 4 views, which i can switch from each to another. What I observed is that every time I use one of the NavigationController buttons to change the View the memory consumption increases by almost 1.5MB. Using the back-button of the

Lost in CUDA device pointers

可紊 提交于 2019-12-25 02:44:25
问题 As part of my thesis work I am working in a CUDA project (modifying somebody elses code, adding functionality, etc). Being new to CUDA this is turning to be a real challenge for me. I am working with compute capability 1.3 cards, 4 x Tesla C1060. And sadly, I am hitting some limitations of the platform. I need to pass a couple of new structures to device, which I believe are been copied correctly. But, when trying to pass the pointers to structure on device on my kernel call I reach the 256

perl regex using too much memory?

我的梦境 提交于 2019-12-25 02:19:27
问题 I have a perl routine that is causing me frequent "out of memory" issues in the system. The script does 3 things 1> get the output of a command to an array (@arr = `$command` --> array will hold about 13mb of data after the command) 2> Use a large regex to match the contents of individual array elements --> The regex is something like this if($new_element =~ m|([A-Z0-9\-\._\$]+);\d+\s+([0-9]+)-([A-Z][A-Z][A-Z])-([0-9][0-9][0-9][0-9]([0-9]+)\:([0-9]+)\:([0-9]+)|io) <put to hash> 3> Put the

What determines how much memory can be allocated?

非 Y 不嫁゛ 提交于 2019-12-25 02:15:57
问题 This is a follow-up to my previous question about why size_t is necessary. Given that size_t is guaranteed to be big enough to represent the largest size of a block of memory you can allocate (meaning there can still be some integers bigger than size_t), my question is... What determines how much you can allocate at once? 回答1: The architecture of your machine, the operating system (but the two are intertwined) and your compiler/set of libraries determines how much memory you can allocate at

local memory address is valid after function return? [duplicate]

人走茶凉 提交于 2019-12-25 01:56:09
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Can a local variable's memory be accessed outside its scope? I was refreshing the knowledge about how memory internally works, and I faced the confusion. Here is sample code int * func(){ int retval = 3; return &retval; } int main(void){ int *ptr = func(); printf("address return from function %p and value %d\n", ptr, *ptr); } My understanding regards how stack memory works on a routine, is when a function was

Potential leak of an object warning — clarification needed

不问归期 提交于 2019-12-25 01:55:48
问题 After I Analyzed my code, Xcode indicated a potential leak as shown below. Is this something I should be concerned about? In this code, the class that sets doublyLinkedList is the sole owner and continues to manage this object throughout program execution. 回答1: You may wish to do this instead: if (self) { DoublyLinkedList *dll = [DoublyLinkedList new]; self.doublyLinkedList = dll; [dll release]; } In the header, declare doublyLinkedList a @property that is retained. 回答2: The reason you're

Error: Variable-sized object may not be initialized. But why?

安稳与你 提交于 2019-12-25 01:53:19
问题 enter code hereint quantity = [array count]; int i; for (i=0; i<quantity; i++) { NSString *imageName = [NSString stringWithFormat:@"Car_%@.jpg", [[array objectAtIndex:i] objectForKey:@"CarName"]] ]; UIImage *img[i] = [UIImage imageNamed:imageName]; UIImageView *imgView[i] = [[UIImageView alloc] initWithImage:img[i]]; imgView[i].frame = CGRectMake(i*kWidth, 0, kWidth, kHeight); [scrollView addSubview:imgView[i]]; [imgView[i] release]; }`enter code here` Error: Variable-sized object may not be

Handling memory leak in cyclic graphs using RefCell and Rc

人走茶凉 提交于 2019-12-25 01:45:56
问题 I followed the approach mentioned in https://ricardomartins.cc/2016/06/08/interior-mutability for creating a graph in Rust using Rc and RefCell . type NodeRef<i32> = Rc<RefCell<_Node<i32>>>; #[derive(Clone)] // The private representation of a node. struct _Node<i32> { inner_value: i32, adjacent: Vec<NodeRef<i32>>, } #[derive(Clone)] // The public representation of a node, with some syntactic sugar. struct Node<i32>(NodeRef<i32>); impl<i32> Node<i32> { // Creates a new node with no edges. fn

A very large square matrix powered by 2

99封情书 提交于 2019-12-25 01:19:37
问题 I have a very large square matrix of order around 570,000 x 570,000 and I want to power it by 2. The data is in json format casting to associative array in array (dict inside dict in python) form Let's say I want to represent this matrix: [ [0, 0, 0], [1, 0, 5], [2, 0, 0] ] In json it's stored like: {"3": {"1": 2}, "2": {"1": 1, "3": 5}} Which for example "3": {"1": 2} means the number in 3rd row and 1st column is 2. I want the output to be the same as json, but powered by 2 (matrix

Received memory warning, while using animations in UIImageview like [smyImageView startAnimating];

最后都变了- 提交于 2019-12-25 01:18:05
问题 //NsMutableArray //Received memory warning, while using animations in UIImageview like; self.imageArray = [[NSMutableArray alloc] initWithCapacity:IMAGE_COUNT]; // Build array of images, cycling through image names if (![self.imageArray count]>0) { for (int i = 0; i < IMAGE_COUNT; i++){ if (i<10) { [self.imageArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"image000%d.jpg", i]]]; }else { [self.imageArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"image00%d.jpg"