Is it safe to delete a void pointer?
Suppose I have the following code: void* my_alloc (size_t size) { return new char [size]; } void my_free (void* ptr) { delete [] ptr; } Is this safe? Or must ptr be cast to char* prior to deletion? ...
Suppose I have the following code: void* my_alloc (size_t size) { return new char [size]; } void my_free (void* ptr) { delete [] ptr; } Is this safe? Or must ptr be cast to char* prior to deletion? ...
It's really strange. I have a blank UIImageView subclass that implements the -touchesEnded:, -touchesMoved, and -touchesBegan: methods. The implementations of these methods are empty. They just do nothing. However, when I run Instruments with "Leaks", and I touch the UIImageView and move my finger outside of that UIImageView while still ...
I have a UIWebView in a viewcontroller, which has two methods as below. The question is if I pop out(tap back on navigation bar) this controller before the second thread is done, the app will crash after [super dealloc], because "Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result...
I need to post a notification using postNotificationName:object:userInfo: method, and I'm passing a custom class FileItem in as userInfo so I can obtain it on the other end. Should I use autorelease like this FileItem *item = [[[FileItem alloc] init] autorelease]; [[NSNotificationCenter defaultCenter] postNotificationName:@"dataReceive...
I have a program that uses way too much memory for allocating numerous small objects on heap. So I would like to investigate into ways to optimize it. The program is compiled with Visual C++ 7. Is there a way to determine how much memory is actually allocated for a given object? I mean when I call new the heap allocates not less than th...
I have a process running 24 hours on my system comtinuously for 45 days. In the morning the number of threads are 20 and in the afternoon the number of threads are 100 and in the evening the number of threads again comes back to 20. But the Mem Usage and VM size values does not come back to the values when the number of threads were just...
Hi all, If you could help me with this dilemma I have. Now, I know C \ C++, I know asm, I know about dll injection, I know about virtual memory addressing, but I just can't figure out how software like CheatEngine, and others, manage to change a variable's value in another process. For those who don't know, 3rd party cheat engine tools ...
Hi Everyone. I'm a beginner at C, Obj-C and the iPhone, and I'm trying getting to grips with a lot of terminology used. I hope one of ye can help with a problem I have been struggling with for a few days now. My code below is a method which call up a nib containing a search field and a table. The table is populated from a search of the...
If you do not free memory that you malloc'd in a C program under Linux, when is it released? After the program terminates? Or is the memory still locked up until an unforseen time (probably at reboot)? ...
I want to get the size of any "record" type in following function. But seems it doesn't work: function GetDataSize(P : Pointer) : Integer; begin Result := SizeOf(P^); // **How to write the code?** end; For example, the size of following record is 8 bytes SampleRecord = record Age1 : Integer; Age2 : Integer; end; But GetDataSize...
Still a little confused about Objective-C memory management. I think my confusion stems from what exactly the autorelease means. NSString *theBackendResponse = [[NSString alloc] initWithData:receivedData encoding:NSASCIIStringEncoding]; NSDictionary *accountDictionary = [theBackendResponse propertyList]; [viewController setAccountDictio...
Hello I'm programming an application in Objective-C and I'm getting this error: MyApp(2121,0xb0185000) malloc: *** error for object 0x1068310: double free *** set a breakpoint in malloc_error_break to debug It is happening when I release an NSAutoreleasePool and I can't figure out what object I'm releasing twice. How do I set his br...
Hi, I've a JME application running in a samsung i617 cell phone, and the applications is throwing OutOfMemoryError when its heap goes over 7.1 MB (and the cell phone has 64 mb)... Is it possible to use the -Xmx and -Xms parameters in JME ...
I am interfacing with an ActiveX component that gives me a memory address and the number of bytes. How can I write a C# program that will access the bytes starting at a given memory address? Is there a way to do it natively, or am I going to have to interface to C++? Does the ActiveX component and my program share the same memory/ad...
I am currently designing a website in C#, which uses some very complex code to generate a search list, which I am currently designing as a Tree-like structure. The main reason I am using a tree is the fact that this website is high-traffic and has a very complex search filter, which means scalability is very important, however I am worr...
Hi All, Here's my problem: I'm trying to parse a big text file (about 15,000 kb) and write it to a mysql database. I'm using python 2.6, and the script parses about half the file and adds it to the database before freezing up. Sometimes it displays the text: MemoryError. Other times it simply freezes. I figured I could avoid this pr...
In a C++ program I write: #include<iostream> #include<vector> using namespace std; int main() { vector<int> a; a.resize(1); for( int i = 0 ; i < 10 ; i++ ) { cout << a[i] << " "; } return 0; } this program prints the correct value of a[0] (because it is allocated) but also prints values at the rest of the 10 lo...
There are a set of memory management algorithms used in operating system construction, like pagination, segmentation, paged segmentation (paginación segmentada), segment pagination (segmentación paginada) and others. Do you know if they are used besides that area, in not so low level software? They are used in bussiness applications? ...
I am currently working on a large-scale website, that is very dynamic, and so needs to store a large volume of information in memory on a near-permanent basis (things like configuration settings for the checkout, or the tree used to implement the menu structure). This information is not session-specific, it is consistent for every threa...
In addition to mark-and-sweep, the garbage collectors for .Net and Java both also run a compaction phase to cut down on memory fragmentation. I am not able to find any documentation on a compaction/defragmentation phase for the Flash 9 garbage collector - does Flash not have any compaction phase? ...