在我的带有内核2.6.18的Fedora Core 9网络服务器上,init并没有收获僵尸进程.如果进程表最终没有达到可以分配新进程的上限,那么这将是可以忍受的.
样本输出ps -el | grep 'Z':
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
5 Z 0 2648 1 0 75 0 - 0 exit ? 00:00:00 sendmail <defunct>
1 Z 51 2656 1 0 75 0 - 0 exit ? 00:00:00 sendmail <defunct>
1 Z 0 2670 1 0 75 0 - 0 exit ? 00:00:02 crond <defunct>
4 Z 0 2874 1 0 82 0 - 0 exit …Run Code Online (Sandbox Code Playgroud) 我在Upstart init进程(pid 1)中有内存泄漏,我在调试时有哪些选项?
编辑:建议我一些真正的工具,手动输入printfs或手动计算内存分配不会削减它.同时转储init核心并探索它并不是一个真正的选择.
UPD1: valgrind不起作用.使用正确的valgrind + init magic替换内核命令行上的/ sbin/init似乎不是一个选项,因为它尝试访问/ proc for self for smaps,但是在init运行之前它们不可用.
UPD2: dmalloc也不起作用(不在ARM上编译).
相当简单的问题:
我的课上有一个init方法,可能会出错.如果确实如此,我打算"返回nil",但我还想返回一个错误.在init方法中使用NSError**参数是不好的做法吗?我的方法声明如下所示:
- (id) initWithArgs:(NSString*) args andError:(NSError**)error;
Run Code Online (Sandbox Code Playgroud)
非常感谢,尼克
我正在做一个关于nettuts的免费jQuery课程,叫做Jeffrey Way学习jquery 30天,我有四件事我真的很难过,首先是这里的代码:
(function() {
$('html').addClass('js');
var contactForm = {
container: $('#contact'),
init: function() {
$('<button></button>', {
text: 'Contact Me'
})
.insertAfter('article:first-child ')
.on('click', this.show);
},
show: function() {
contactForm.container.slideDown(500);
}
};
contactForm.init();
})();
Run Code Online (Sandbox Code Playgroud)
当您单击网站上的"与我联系"按钮时,它基本上会滑下联系表单.我的问题是:
.on('click', this.show);你为什么需要this在this.show?contactForm.container.slideDown(500);为什么不能只是说container.slideDown(500);或$('form.contact').slideDown(500); (顺便说一下,滑下来的形式的id是contact.关于将信号9(SIGKILL)发送到init进程(PID 1),我遇到了一个奇怪的问题.您可能知道,SIGKILL不能通过信号处理程序忽略.当我尝试将SIGKILL发送给init时,我发现没有发生任何事情; init不会被终止.试图弄清楚这种行为,我决定将自己附加到使用strace的init进程,也可以更清楚地看到发生了什么.现在是奇怪的部分.如果我用strace"查看"init进程并发送SIGKILL,系统崩溃了.
我的问题是为什么会发生这种情况?为什么在我查看流程时系统崩溃,为什么在我不这样做时它不会崩溃?正如我所说,在这两种情况下我都将SIGKILL发送给init.在CentOS 6.5,Debian 7和Arch上测试过.
谢谢!
就像UILabel类一样:
class UILabel : UIView, NSCoding {
var text: String! // default is nil
var font: UIFont! // default is nil (system font 17 plain)
var textColor: UIColor! // default is nil (text draws black)
var shadowColor: UIColor! // default is nil (no shadow)
var shadowOffset: CGSize // default is CGSizeMake(0, -1) -- a top shadow
....
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我定义一个这样的类,它也没有init函数.编译器会警告我.我怎么能像苹果那样做,隐藏实现,只声明接口.谢谢.
是否有可能,如果是的话,如何在没有参数的情况下使用多个init,在这样的类中(字符串只是一个例子):
aVar: String
init() {
aVar = "simple init"
}
initWithAGoodVar() {
aVar = "Good Var!"
}
initWithFooBar() {
aVar = "Foo Bar"
}
Run Code Online (Sandbox Code Playgroud) 我有一个带有两个init方法的对象.其中一个接受NSDictionary,另一个接收大量的String变量.我想调用NSDictionary init,然后将我的字典转换为字符串并使用我的字符串调用其他init.这是我的代码:
init(data: NSDictionary) {
self = Event(data["event_id"] as! String, eventName: data["event_name"] as! String, eventDescription: data["description"] as! String, eventCategories: data["categories"] as! [String], eventSecurity: data["event_security"] as! String, authorUserID: data["author_user_id"] as! String, timestampCreated: data["timestamp_created"] as! String, timestampUpdated: data["timestamp_updated"] as! String, startDateTime: data["start_date_time"] as! String, endDateTime: data["end_date_time"] as! String, location: Location(streetAddress: data["location_street_address"] as! String, city: data["location_city"] as! String, state: data["location_state"] as! String, zipCode: data["location_zipcode"] as! String, countryCode: data["location_country_code"] as! String), reoccurDateStart: data["reoccur_date_start"] as! String, reoccurDateEnd: data["reoccur_date_end"] as! String, reoccurDaysOfWeek: data["reoccur_days_of_week"] as! String, eventType: …Run Code Online (Sandbox Code Playgroud) 我正在分析其中有两个类似init的文件的python代码。名称为__init__solvers.py和__init__cases.py,它们包含典型的__init__.py结构和初始化数据。例如,__init__solvers.py包含以下内容:
# List of solvers
solvers = ["s1", "s2", "s3"]
# Wrapper for solvers
def Solver(choice, options):
"Return solver instance for given choice"
exec("from %s import Solver as ChosenSolver" % choice)
return ChosenSolver(options)
Run Code Online (Sandbox Code Playgroud)
主模块按如下方式导入求解器和求解器:
from solvers import Solver, solvers
Run Code Online (Sandbox Code Playgroud)
对的内容执行了类似的方法__init__cases.py。它是为Python 2.x编写的。目录结构如下所示:
main/
__init__.py
mainmodule.py
solversandcases/
__init__solvers.py
__init__cases.py
basicsolver.py # where BasicSolver() class is defined
basiccase.py # where BasicCase() class is defined
s1.py # where Solver(BasicSolver) class is defined
c1.py # …Run Code Online (Sandbox Code Playgroud)