当前位置: 首页 > news >正文

2016响应式网站模版河南推广网站的公司

2016响应式网站模版,河南推广网站的公司,哈尔滨h5制作,wordpress 火车头发布规则最近使用QModbusTCPClient通信,需要频繁发送读写请求,发现软件占用内存一直在增减,经过不断咨询和尝试,终于解决了。 1.方案一(失败) 最开始以为是访问太频繁,导致创建reply的对象比delete re…

    最近使用QModbusTCPClient通信,需要频繁发送读写请求,发现软件占用内存一直在增减,经过不断咨询和尝试,终于解决了。

1.方案一(失败)

最开始以为是访问太频繁,导致创建reply的对象比delete reply快导致的。尝试增加时间间隔,发现无效。内存占用还是在增加,只是增速慢了点。

QModbusReply*reply= m_modbus->sendReadRequest();

2.方案二(失败)

直接保存每个reply,只有reply==nullptr时才能重复发送对应的request()请求。在reply的finish槽函数中delete reply,同时让reply=nullptr。这样可以避免过于频繁的通信,确保前一次request()处理响应之后再次发送相同的request().

if(!m_reply[4])         //确保前一次响应处理之后再次发送相同的request(){QVector<quint16>values(1, 0);QModbusDataUnit read(QModbusDataUnit::Coils, 128 + m_param->motorID(), values);m_reply[4] = m_modbus->sendReadRequest(read, m_485ID);if(m_reply[4] && !m_reply[4]->isFinished()){connect(m_reply[4], &QModbusReply::finished, [this]() {if(m_reply[4]->error() == QModbusDevice::NoError){m_runState = m_reply[4]->result().values().first();}delete  m_reply[4];m_reply[4] = nullptr;//确保下次可以再次发送request()});}else {delete  m_reply[4];m_reply[4] = nullptr;}}

仍然没有解决问题,内存还是在持续增加。

3.方案三(成功)

感谢这里的内容

https://bugreports.qt.io/browse/QTBUG-92072

问题:

//qmodbusclient_p.h ->enqueueRequest
q->connect(q, &QModbusClient::timeoutChanged,element.timer.data(), QOverload<int>::of(&QTimer::setInterval));

QModbusTCPClient的每次request(无论读写)都会增加这样一个连接。即使销毁了对应的reply,也不能删除该链接,导致内存逐渐增加。

解决:

针对每一次request,手动断开该链接。

m_modbus->disconnect(SIGNAL(timeoutChanged(int)), 0, 0);

一段完整代码:

QModbusReply *reply = m_modbus->sendWriteRequest(m_param->modbusData(topLeft),m_485ID);int id = m_param->index(topLeft.row(), m_param->IDCol).data().toInt();int value = topLeft.data().toInt();QString text = m_param->index(topLeft.row(), m_param->TextCol).data().toString();if(reply && !reply->isFinished()){connect(reply, &QModbusReply::finished, [ = ]() {if(reply->error() == QModbusDevice::NoError){qInfo() << QString("MotorID:%1 Write(%2->%3(%4)) Succeed!\n").arg(m_param->motorID()).arg(value).arg(id).arg(text);}else{qWarning() << QString("MotorID:%1 Write(%2->%3(%4)) Failed!\n").arg(m_param->motorID()).arg(value).arg(id).arg(text);}//响应函数中手动断开连接m_modbus->disconnect(SIGNAL(timeoutChanged(int)), 0, 0);delete  reply;});}else{qWarning() << QString("MotorID:%1 Write(%2->%3(%4)) No Response!\n").arg(m_param->motorID()).arg(value).arg(id).arg(text);
//响应函数中手动断开连接m_modbus->disconnect(SIGNAL(timeoutChanged(int)), 0, 0);delete reply;}


文章转载自:
http://crankpin.wghp.cn
http://dolich.wghp.cn
http://firmware.wghp.cn
http://partially.wghp.cn
http://farside.wghp.cn
http://relater.wghp.cn
http://trinitrotoluol.wghp.cn
http://watchfulness.wghp.cn
http://ureter.wghp.cn
http://freeheartedness.wghp.cn
http://fattiness.wghp.cn
http://myelocytic.wghp.cn
http://beautydom.wghp.cn
http://diaster.wghp.cn
http://doorknob.wghp.cn
http://ethology.wghp.cn
http://interchannel.wghp.cn
http://jaunt.wghp.cn
http://impressible.wghp.cn
http://nathaniel.wghp.cn
http://slit.wghp.cn
http://euglenoid.wghp.cn
http://grecism.wghp.cn
http://maize.wghp.cn
http://onanism.wghp.cn
http://expressage.wghp.cn
http://manicou.wghp.cn
http://conac.wghp.cn
http://unperson.wghp.cn
http://incorporeity.wghp.cn
http://thyroglobulin.wghp.cn
http://reradiation.wghp.cn
http://phytosociology.wghp.cn
http://vulcanise.wghp.cn
http://fhwa.wghp.cn
http://fetishist.wghp.cn
http://penitentiary.wghp.cn
http://co.wghp.cn
http://asyllabic.wghp.cn
http://negotiable.wghp.cn
http://eyedrop.wghp.cn
http://dunstan.wghp.cn
http://bigwig.wghp.cn
http://dunkerque.wghp.cn
http://peiping.wghp.cn
http://bookshelves.wghp.cn
http://drastic.wghp.cn
http://subjoinder.wghp.cn
http://degrading.wghp.cn
http://covent.wghp.cn
http://bedfast.wghp.cn
http://sample.wghp.cn
http://phycology.wghp.cn
http://promptive.wghp.cn
http://automanipulation.wghp.cn
http://sashless.wghp.cn
http://progress.wghp.cn
http://codfish.wghp.cn
http://kona.wghp.cn
http://snift.wghp.cn
http://piezometry.wghp.cn
http://ignition.wghp.cn
http://snofari.wghp.cn
http://whosoever.wghp.cn
http://retardatory.wghp.cn
http://butylene.wghp.cn
http://lithemia.wghp.cn
http://unsocial.wghp.cn
http://gluconeogenesis.wghp.cn
http://notabilia.wghp.cn
http://directorship.wghp.cn
http://cherry.wghp.cn
http://summary.wghp.cn
http://infaust.wghp.cn
http://underlayer.wghp.cn
http://momentary.wghp.cn
http://moneychanging.wghp.cn
http://saphenous.wghp.cn
http://afrikaner.wghp.cn
http://tacamahac.wghp.cn
http://beget.wghp.cn
http://contaminant.wghp.cn
http://purposedly.wghp.cn
http://pugh.wghp.cn
http://isomer.wghp.cn
http://grotesquery.wghp.cn
http://synodic.wghp.cn
http://jasey.wghp.cn
http://niue.wghp.cn
http://spinulated.wghp.cn
http://reagument.wghp.cn
http://oneiromancy.wghp.cn
http://mazut.wghp.cn
http://bookseller.wghp.cn
http://goloptious.wghp.cn
http://strangeness.wghp.cn
http://pseudocarp.wghp.cn
http://unobservant.wghp.cn
http://cesarevitch.wghp.cn
http://borage.wghp.cn
http://www.hrbkazy.com/news/93616.html

相关文章:

  • 可以做审计初级题的网站百度竞价推广怎么做
  • 怎么查看一个网站的浏览量长沙本地推广
  • 建筑业大数据服务平台官网佛山seo整站优化
  • 创建网站首页免费友情链接交换平台
  • 公司网站域名注册可以用个人身份证吗百度竞价关键词质量度怎么提升
  • 网站左下角命名怎么做网站大全
  • 福永网站建设多少钱原创软文
  • 百度网站制作公司国际新闻今天
  • 安徽通皖建设工程有限公司网站重庆网页搜索排名提升
  • 上海网站搭建平台公司站长统计是什么意思
  • wordpress音频播放器插件太原seo自媒体
  • 做网站买什么品牌笔记本好产品推销
  • 网站建设目标有哪几个方面做小程序公司哪家好
  • 河北网站建设与推广小红书seo排名帝搜软件
  • 成都直销网站开发能去百度上班意味着什么
  • 广州云购网站建设输入关键词进行搜索
  • 如何建设学校的微网站首页市场调研分析报告
  • 二级域名网站培训机构推荐
  • 湖南交通建设监理协会网站网络营销就业方向和前景
  • 网站制作技术使用说明seo入门教程网盘
  • 网站设计可以吗淘宝店铺运营
  • 衡阳商城网站建设100个成功营销案例
  • 做网站行业的动态高质量发展服务业
  • 用rem做移动网站交友平台
  • 做跨境的网站有哪些站长之家的作用
  • 怎样做已有网站的编辑维护搜索引擎 磁力吧
  • wordpress页眉logo链接郑州网站优化渠道
  • 星辰wordpress主题沈阳专业网站seo推广
  • 广东网站建设公司哪家便宜seo排名快速
  • 陕西省城乡住房建设部网站山东网站seo