New to Cocoa and Objective-c.
Do I need getters and setters if I'm depending on garbage collection?
For example is it safe to just modify instance variables directly without the dot syntax?
And in the dealloc method can I sent them to nil instead of release (or do I even have to release them)?
...
Into a class constructor, I need to create some objects on the fly and add them to a vector. Here is my code:
ContainerClass::ContainerClass() {
for (int i = 0; i < limit; i++)
elements.push_back(SubElement());
}
Is this the same thing with new SubElement()? Do I still need to free those SubElement() objects into the Containe...
I am a big fan of GCC, but recently I noticed a vague anomaly. Using __gnu_cxx::__normal_iterator (ie, the most common iterator type used in libstdc++, the C++ STL) it is possible to refer to an arbitrary memory location and even change its value without causing an exception! Is this expected behavior? If so, isn't a security loophole?
...
Is this the right way to return an object from a function?
Car getCar(string model, int year) {
Car c(model, year);
return c;
}
void displayCar(Car &car) {
cout << car.getModel() << ", " << car.getYear() << endl;
}
displayCar(getCar("Honda", 1999));
I'm getting an error, "taking address of temporary". Should I use this way:...
I'm getting the java.lang.OutOfMemoryError exception in Eclipse. I know that Eclipse
by default uses heap size of 256M. I'm trying to increase it but nothing happens.
For example:
eclipse -vmargs -Xmx16g -XX:PermSize=2g -XX:MaxPermSize=2g
I also tried different settings, using only the -Xmx option, using different cases
of g, G, m, M,...
Hi,
I am currently writing a small custom memory Allocator in c++, and want to use it together with operator overloading of new/delete. Anyways, my memory Allocator basicall checks if the requested memory is over a certain threshold, and if so uses malloc to allocate the requested memory chunk. Otherwise the memory will be provided by s...
I have a C++ program which, during execution, will allocate about 3-8Gb of memory to store a hash table (I use tr1/unordered_map) and various other data structures.
However, at the end of execution, there will be a long pause before returning to shell.
For example, at the very end of my main function I have
std::cout << "End of execut...
Is loading only the needed classes directly a good way of reducing the overall memory usage of a Java application?
For example:
import java.awt.Graphics;
vs
import java.awt.*;
...
Hi,
I am currently working on some simple custom allocators in c++ which generally works allready. I also overloaded the new/delete operators to allocate memory from my own allocator. Anyways I came across some scenarios where I don't really know where the memory comes from like this:
void myFunc(){
myObj testObj();
...
I have a root UIViewController which has a property called webView. WebView is a UIViewController with a XIB that contains a UIWebView. From my root view I modally (is there any other way?) load the webView ViewController and set its URL, always to the same page.
I discovered that if, after loading the webView, I used its default Web pa...
I want to get the "free memory" of a bunch of servers like this:
def get_mem(servername):
res = os.popen('ssh %s "grep MemFree /proc/meminfo | sed \'s/[^0-9]//g\'"' % servername)
return res.read().strip()
since this can be threaded I want to do something like that:
import threading
thread1 = threading.Thread(target=ge...
I have successfully installed a 64 bit Fedora 11 guest os using VirtualBox on a host machine (AMD64) running 32 bit Windows XP .
At the moment the host machine has 2 Gb ram installed and I've allocated 1 Gb to the guest, which all works well.
The host machine can hold a maximum of 4 Gb ram, so I was wondering if it's worth buying an ex...
Say I have two classes created work and workItem.
CWorker *work = new CWorker();
CWorkItem *workItem = new CWorkItem();
The work class has a public list m_WorkList and I add the work item to it.
work->m_WorkList.push_back(workItem);
If I just delete work
if(work != NULL)
delete work;
Do I need to loop through th...
I can't seem to get a simple program (with lots of memory access) to achieve consistent timing in Linux. I'm using a 2.6 kernel, and the program is being run on a dual-core processor with realtime priority. I'm trying to disable cache effects by declaring the memory arrays as volatile. Below are the results and the program. What are some...
I have a .Net application running on a 32 bit box. The application is a windows service. It consistently hovers around 600-800 MB range. Is this a problem. If an application crosses 1 GB, is it a memory issue ?
...
I've been trying to design a program that makes 2D animations and then uses the ffmpeg library to create the video for possible use in tv and movies. The problem is when I think about how to manage the data in the application I can only think of two ways, I don't think either of them will work out very well. One is to use an SQlite datab...
I have an array of bytes, in memory. What's the fastest way to see if all the bytes in the array are zero?
...
I have read a lot of posts about "string literals" on SO, most of which have been about best-practices, or where the literal is NOT located in memory.
I am interested in where the string DOES get allocated/stored, etc.
I did find one intriguing answer here, saying:
Defining a string inline actually embeds the data in the program it...
Hi Everyone,
Is it possible to get the memory address of a variable in C#.
What I am trying to do is very simple. I want to declare variables of type Double,
Float, Decimal and assign the value 1.1 to each of these variables. Then I would like
to go and see how these values are represented in memory. I need to get the memory
addres...
Okay, so I've written a (rather unoptimized) program before to encode images to JPEGs, however, now I am working with MPEG-2 transport streams and the H.264 encoded video within them. Before I dive into programming all of this, I am curious what the fastest way to deal with the actual file is.
Currently I am file-mapping the .mts file ...