解决Webbrowser定时抓取网页数据时,内存累积不释放的问题

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/yangliu0512/article/details/78340431

原因:重复的Dim Web As New Webbrowser。感觉这是Webbrowser的Bug,重复的创建不能释放调用Dispose也没用。

解决办法:定义为全局变量,只创建一次。

展开阅读全文

请教抓取网页数据问题(使用HtmlAgilityPack、WebBrowser

12-02

[b]目标网页:[/b]http://fund.eastmoney.com/data/fundranking.html#tzq;c0;r;s1nzf;pn10000;ddesc;qsd20141201;qed20151201;qdii;zq;gg;gzbd;gzfs;bbzt;sfbbrn[b]目的:[/b]为了获取页面列出的基金代码和名称rn[b]抓取工具:[/b]HtmlAgilityPackrn[b]问题描述:[/b]1、在WebBrowser加载页面成功后,采用插入js代码的方法获取网页源码,当使用LoadHtml方法时无法看到有关“基金代码”和“名称”的节点(在浏览器用审查元素可以看到)rn 2、这种方法在抓取新浪页面数据时可行,(附sina地址:http://vip.stock.finance.sina.com.cn/fund_center/index.html#jzkfzqx)是否跟页面实现的方式有关。请各位不吝赐教,谢谢。rn[b]主要代码如下:[/b]rn[code=csharp]rn ……rn string destinationNet = "http://fund.eastmoney.com/data/fundranking.html#tzq;c0;r;s1nzf;pn10000;ddesc;qsd20141201;qed20151201;qdii;zq;gg;gzbd;gzfs;bbzt;sfbb";rn targetWeb.Navigate(destinationNet);rn HtmlAgilityPack.HtmlDocument hapHtmlDoc = new HtmlAgilityPack.HtmlDocument();rn //插入jsrn HtmlElement injectFuntion = targetWeb.Document.CreateElement("script");rn injectFuntion.SetAttribute("type", "text/javascript");rn injectFuntion.SetAttribute("text", @"function getHTML()var result=document.documentElement.outerHTML;return result;");rn targetWeb.Document.Body.AppendChild(injectFuntion);rn //===========rn object targetHTML = targetWeb.Document.InvokeScript("getHTML");//获取源码rn hapHtmlDoc.LoadHtml(targetHTML.ToString());rn ……rn[/code] 论坛

UIDatePicker 内存释放

09-01

请教各位大侠,rnrnself.window = [[UIWindow alloc] init];rn self.window.frame = CGRectMake(0, 0, self.width, self.height);rn self.window.backgroundColor = [UIColor colorWithRed:0/255.0f green:0/255.0f blue:0/255.0f alpha:0.5];rn self.window.windowLevel = UIWindowLevelStatusBar;rn [self.window makeKeyAndVisible];rn UIControl * touchControl = [[UIControl alloc] initWithFrame:CGRectMake(0, 0, self.width,self.height)];rn [self.window addSubview:touchControl];rn [touchControl addTarget:selfrn action:@selector(TouchDown)rn forControlEvents:UIControlEventTouchDown];rn rn self.datePickerView = [[UIDatePicker alloc] init];rn self.datePickerView.center = CGPointMake(160, 220);rnrn self.datePickerView.datePickerMode=UIDatePickerModeDate;rn //添加事件rn [self.datePickerView addTarget:self action:@selector(datePickerDateChanged:) forControlEvents:UIControlEventValueChanged];rn rn //获得当前时间rn NSDate *currentDate = self.datePickerView.date;rn NSLog(@"Date = %@",currentDate);rn [self.window addSubview:self.datePickerView];rn rn self.birthdayTempStr = [NSString stringWithFormat:@"%@",[[currentDate description] substringToIndex:10]];rn NSString *birthday = @"";rn FYFriendTime *birthdayUtil = [[FYFriendTime alloc] init];rn char *birthdayChar = CoreService::getSharedService()->GetApp().GetAccount().GetBirthday();rn NSString *birthdayStr = [NSString stringWithCString:birthdayChar encoding:NSUTF8StringEncoding];rn birthday = [birthdayUtil birthdayDate:birthdayStr];rn if (birthday.length != 0)rn rn NSDateFormatter *dateFomatter = [[NSDateFormatter alloc] init];rn [dateFomatter setDateFormat:@"yyyy-MM-dd"];rn NSDate *date = [dateFomatter dateFromString:birthday];rn [self.datePickerView setDate:date animated:NO];rn self.birthdayTempStr = birthday;rn rn rn UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(100, 440, 120, 35)];rn [btn setTitle:@"确定" forState:UIControlStateNormal];rn [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];rn btn.backgroundColor = [UIColor greenColor];rn btn.tag = 1002;rn [btn addTarget:self action:@selector(confirmBirthday) forControlEvents:UIControlEventTouchUpInside];rn [self.window addSubview:btn];rnrn-(void) datePickerDateChanged:(UIDatePicker *)paramDatePickerrn if ([paramDatePicker isEqual:self.datePickerView]) rn NSDate *currentDate = paramDatePicker.date;rn // NSString * todayString = [[currentDate description] substringToIndex:10];rn // NSLog(@"Selected date=%@",todayString);rn NSDateFormatter *farmatter = [[NSDateFormatter alloc] init];rn [farmatter setDateFormat:@"yyyy-MM-dd"];rn NSString *str = [farmatter stringFromDate:currentDate];rn self.birthdayTempStr = str;rn rnrn-(void)TouchDownrnself.datePickerView = nil;rnself.window = nil;rnrn 论坛

内存释放???

04-24

各位好!请教个问题,我不断地往oracle里插入数据,oracle会出现内存不断飙升,o只到电脑内存不足而挂掉。rn系统为WINDOWS 2003,rn刚开启时,ORACLE.EXE使用内存为200M左右,任务管理器下的显示内存使用为1020M/3428M;rn运行几个小时后,ORACLE.EXE使用内存变为600M,而任务管理器下显示内存使用高达2987M/3428M。rn请问是什么原因呢?谢谢了。。。rnrn插入测试代码如下:rn [code=C/C++]rn int main() rn rn Environment * env = Environment::createEnvironment( " ZHS16GBK " , " UTF8 " );rn char *szInsert = "某插入语句"; rnrn string mc;rn rn Connection * conn = env->createConnection( " system " , " system " , " orcl_192.168.0.3 " );rn rn try rn rn while (1)rn rn Statement * stmt = conn->createStatement(szInsert );rn stmt->executeUpdate();rn conn->terminateStatement(stmt);rn conn->commit();rn Sleep(10); //10毫秒rn rn rn catch (SQLException e)rn rn cout << e.what();rn rn env -> terminateConnection(conn);rn rn Environment::terminateEnvironment(env);rn system( " pause " );rn return 0 ;rn[/code]rnrn rn最初我以为是createStatement操作造成内存没释放,后来我改为只创建一次,但是还是出现内存不断飙升不释放的问题。rn[code=C/C++] rn try rn rn Statement * stmt = conn->createStatement(szInsert );rn while (1)rn rn stmt->executeUpdate();rn conn->commit();rn Sleep(10); //10毫秒rn rn conn->terminateStatement(stmt);rn rn catch (SQLException e)rn rn cout << e.what();rn [/code]rnrnrn请问是什么原因呢?谢谢。。。。rn 论坛

没有更多推荐了,返回首页