memory-management

WCF - Is that good to use “DataSet” for transferring data through NetTcpBinding

痴心易碎 提交于 2020-01-05 08:09:43
问题 One of by service contract passes a Huge DataSet to the Client. I am using BufferedTranfer mode. In very rare cases I have more data to be send, because of this reason I am in a confusion to change the TransportMode to Streamed. Is that good practice to use "DataSet" for transfer data through NetTcpBinding ? Any alternatives to DataSets ? 回答1: Please, do not return datasets from a WCF service. For information why see: Returning DataSets from WebServices is the Spawn of Satan and Represents

iOS memory management - clarifications

好久不见. 提交于 2020-01-05 07:44:10
问题 I know that alloc and retain will increase the reference count of an object. Is there any other different method that actually increment the reference count? And when/how does dealloc is called? 回答1: With these the retain count gets increased. new, however it can be seen as alloc+init. retain copy creates new object with retain count=1 mutableCopy creates new object with retain count=1 dealloc is called automatically as soon as retain count reaches to 0. 回答2: alloc allocates an object with

How should I store a large string, like a user agreement? [closed]

三世轮回 提交于 2020-01-05 07:27:50
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I can use a string literal like @"content" , but I think it’s a waste of memory. Is there a custom solution for this situation? I'm a new Xcoder, so may be this is not a good question, but I'm very confuse about

== with Abstract datatypes, different results for the same kind of conditions [duplicate]

谁都会走 提交于 2020-01-05 07:20:12
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Integer wrapper objects share the same instances only within the value 127? public class test { public static void main(String args[]) { Integer a1=127; Integer a2=127; System.out.println(a1==a2); //output: true Integer b1=128; Integer b2=128; System.out.println(b1==b2); //output: false Long c1=127L; Long c2=127L; System.out.println(c1==c2); // output: true Long d1=128L; Long d2=128L; System.out.println(d1==d2);

C++ memory leak with class members

南笙酒味 提交于 2020-01-05 06:50:34
问题 Debug_VLD in VS2010 reveals some memory leaks that come from class member creation / initialization / deletion. my_member is a data member with type double*. In constructor, I have my_member = NULL ; Then in some method, i need to allocate memory for my_member . I cannot do so in constructor, since i dont know size of array yet, and/or size may different for different calls of the method. What i do in this method is checking if member is NULL. if so, i allocate space for it, if not, i can

Getting no segmentation fault when exceeding the size that was allocated for a char * [duplicate]

被刻印的时光 ゝ 提交于 2020-01-05 04:36:15
问题 This question already has answers here : Array index out of bound in C (10 answers) Closed 4 years ago . I use malloc to allocate n (string length of y) bytes for x. However after copying y to x , I added 3 more characters including '\0' in x and i got no error. Shouldn't I get an error for trying to assign values to unallocated memory since I've allocated space enough for only 10 characters? Is this undefined behavior? #include <stdio.h> #include <stdlib.h> #include <string.h> int main(int

What's the difference between memory allocation and garbage collection, please?

爱⌒轻易说出口 提交于 2020-01-05 04:35:12
问题 I understand that 'Garbage Collection' is a form of memory management and that it's a way to automatically reclaim unused memory. But what is 'memory allocation' and the conceptual difference from 'Garbage Collection'? 回答1: They are Polar opposites . So yeah, pretty big difference. Allocating memory is the process of claiming a memory space to store things. Garbage Collection (or freeing of memory) is the process of releasing that memory back to the pool of available memory. Many newer

Objects creation and instantiation in objective-c

爱⌒轻易说出口 提交于 2020-01-05 04:32:32
问题 Given the piece of code below where blueViewController is an iVar. Question: Why not instantiate the iVar directly? BlueViewController *blueController = [[BlueViewController alloc]initWithNibName:@"BlueView" bundle:nil]; self.blueViewController = blueController; [blueController release]; 回答1: It depends on where you are in your class. If you are in your init (and dealloc) method it is recommended to refer to the ivar directly to avoid any side effects in setter logic. Therefore in the init I

Why does calling malloc() not make a difference?

早过忘川 提交于 2020-01-05 04:02:21
问题 Here's a basic example: #include <all the basic stuff> int main(void) { char *name = (char *) malloc(2 * sizeof(char)); if(name == NULL) { fprintf(stderr, "Error: Unable to allocate enough memory!\n"); return EXIT_FAILURE; } strcpy(name, "Bob Smith"); printf("Name: %s\n", name); free(name); return EXIT_SUCCESS; } Because I'm only allocating 2 bytes of information (2 chars), there should be some sort of error when I perform strcpy, right? This doesn't happen, instead it just copies the string

Are objects in Objective-C ever created on the stack?

别来无恙 提交于 2020-01-05 03:18:07
问题 As far as I understand, in C++ you can create objects on the stack: SomeClass object = SomeClass(); or on the heap: SomeClass *object = new SomeClass(); In Objective-C you always seem to create objects on the heap, as [SomeClass alloc] returns a pointer to a new instance. Is this correct? Are objects ever allocated on the stack? If so, what would be a good example? Else, why not? 回答1: The short answer is that objects are always allocated on the heap, not on the stack. This isn't quite the