On Mon, Jun 20, 2011 at 12:26 AM, Bing Li <[email protected]> wrote: > Dear all, > > I am still a new programmer of Cocoa. In my program, at least right now, > there are no memory leaks according to Instruments. Is it good enough for > memory management?
No. This is not good enough. If you are doing your memory management at the objc level, you should read the memory management guide very carefully. Especially look into autorelease, as the "memory goes up a bunch, then drops when the next event loop spins" sounds much like the standard autorelease behavior. If you are doing it at the C (malloc/free) or CF (some fn call that says CF...Alloc or CF...Retain and corresponeding CF...Free/Release) levels, read the APIs that go along with those, and figure out when your memory is being allocated and when it is being freed or released back to the system. > > What I designed is a TCP server which receives TCP messages. When I tested > it, 200,000 XML were sent to it with a loop without any delays. Each XML had > 800 bytes. In this case, no any memory leaks when testing it with > Instruments. However, according to Activity Monitor, the consumed memory was > increased from 17.9M to more than 400M. Immediately after the sending, the > consumed memory started to be lowered until it was stopped to 100M. Was it > normal? Why wasn't it 17.9M eventually? Sounds like your program still owns some memory, and is holding on to too much memory during execution. Neither ActivityMonitor nor Instruments is a true memory profiler, but they are good ways to figure out some areas where you might have a problem. The true lesson - learn ObjC or C memory management, and do it right every time, or leak RAM and have angry users. You are doing the right thing by asking here for pointers. Scott > > Thanks so much for your help! > > Best, > greatfree > _______________________________________________ > > Cocoa-dev mailing list ([email protected]) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > http://lists.apple.com/mailman/options/cocoa-dev/scott_ellsworth%40alumni.hmc.edu > > This email sent to [email protected] > _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
