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

网站关键词优化方案中国企业500强排行榜

网站关键词优化方案,中国企业500强排行榜,内蒙古微网站建设,淘宝网站建设需求分析文章目录 一、什么是直接内存?二、特点三、使用案例四、直接内存的管理 一、什么是直接内存? Direct Memory:系统内存 普通IO,运行原理图 磁盘到系统内存,系统内存到jvm内存。 NIO,运行原理图 划分了一块…

文章目录

  • 一、什么是直接内存?
  • 二、特点
  • 三、使用案例
  • 四、直接内存的管理

一、什么是直接内存?

Direct Memory:系统内存

普通IO,运行原理图
磁盘到系统内存,系统内存到jvm内存。
在这里插入图片描述
NIO,运行原理图
划分了一块区域,JVM和系统共享的内存区间,这样,就减少了一次IO操作。
在这里插入图片描述

二、特点

常见于 NIO 操作时,用于数据缓冲区
分配回收成本较高,但读写性能高
不受 JVM 内存回收管理

所以,我们可以在IO程序中,使用直接内存来优化程序的读写性能。

三、使用案例

关键代码:ByteBuffer.allocateDirect(_1Mb);

public class Demo1_9 {static final String FROM = "E:\\sbPSjI4tt10.mp4";static final String TO = "E:\\a.mp4";static final int _1Mb = 1024 * 1024;public static void main(String[] args) {io(); // io 用时:1535.586957 1766.963399 1359.240226directBuffer(); // directBuffer 用时:479.295165 702.291454 562.56592}private static void directBuffer() {long start = System.nanoTime();try (FileChannel from = new FileInputStream(FROM).getChannel();FileChannel to = new FileOutputStream(TO).getChannel();) {ByteBuffer bb = ByteBuffer.allocateDirect(_1Mb);while (true) {int len = from.read(bb);if (len == -1) {break;}bb.flip();to.write(bb);bb.clear();}} catch (IOException e) {e.printStackTrace();}long end = System.nanoTime();System.out.println("directBuffer 用时:" + (end - start) / 1000_000.0);}private static void io() {long start = System.nanoTime();try (FileInputStream from = new FileInputStream(FROM);FileOutputStream to = new FileOutputStream(TO);) {byte[] buf = new byte[_1Mb];while (true) {int len = from.read(buf);if (len == -1) {break;}to.write(buf, 0, len);}} catch (IOException e) {e.printStackTrace();}long end = System.nanoTime();System.out.println("io 用时:" + (end - start) / 1000_000.0);}
}

但是,直接内存,是不受JVM管理的
另外,我们显示调用gcJVM也不是立马就执行gc

而且,一般我们会在项目中禁用显示调用gc,因为,Full GC影响性能。
禁用参数:-XX:+DisableExplicitGC

四、直接内存的管理

底层是如何回收直接内存的?

  • 使用了 Unsafe 对象完成直接内存的分配回收,并且回收需要主动调用 freeMemory 方法
  • ByteBuffer 的实现类内部,使用了 Cleaner (虚引用)来监测 ByteBuffer 对象,一旦
    ByteBuffer 对象被垃圾回收,那么就会由 ReferenceHandler 线程通过 Cleanerclean 方法调
    freeMemory 来释放直接内存
    在这里插入图片描述
    我们知道,不建议程序员显示调用gc,来回收JVM对象。
    但是,等待JVM自主的Full GC,又是不确定的。
    所以,还是,建议我们自己手动回收直接内存。
public class Demo1_27 {static int _1Gb = 1024 * 1024 * 1024;public static void main(String[] args) throws IOException {Unsafe unsafe = getUnsafe();// 分配内存long base = unsafe.allocateMemory(_1Gb);unsafe.setMemory(base, _1Gb, (byte) 0);System.in.read();// 释放内存unsafe.freeMemory(base);System.in.read();}public static Unsafe getUnsafe() {try {Field f = Unsafe.class.getDeclaredField("theUnsafe");f.setAccessible(true);Unsafe unsafe = (Unsafe) f.get(null);return unsafe;} catch (NoSuchFieldException | IllegalAccessException e) {throw new RuntimeException(e);}}
}

文章转载自:
http://wanjiacongressional.xhqr.cn
http://wanjiameliorable.xhqr.cn
http://wanjiaamphitheatre.xhqr.cn
http://wanjiaconterminal.xhqr.cn
http://wanjiadisfranchise.xhqr.cn
http://wanjiapodiatry.xhqr.cn
http://wanjiaotoscope.xhqr.cn
http://wanjiayarraman.xhqr.cn
http://wanjiagrave.xhqr.cn
http://wanjiacharactron.xhqr.cn
http://wanjiacellaret.xhqr.cn
http://wanjiaseminomata.xhqr.cn
http://wanjiahylomorphic.xhqr.cn
http://wanjiapeascod.xhqr.cn
http://wanjiahalomethane.xhqr.cn
http://wanjiapeafowl.xhqr.cn
http://wanjiabalconied.xhqr.cn
http://wanjiascrapground.xhqr.cn
http://wanjiaclavioline.xhqr.cn
http://wanjiacirculatory.xhqr.cn
http://wanjiarevolutionize.xhqr.cn
http://wanjiahydrodesulfurization.xhqr.cn
http://wanjiabrno.xhqr.cn
http://wanjiadepress.xhqr.cn
http://wanjiaelectrotechnician.xhqr.cn
http://wanjiaunlettered.xhqr.cn
http://wanjiashibilant.xhqr.cn
http://wanjiastorewide.xhqr.cn
http://wanjiastracciatella.xhqr.cn
http://wanjiainsupportable.xhqr.cn
http://wanjiacroquette.xhqr.cn
http://wanjiapagehood.xhqr.cn
http://wanjiatransport.xhqr.cn
http://wanjiapaleness.xhqr.cn
http://wanjiagah.xhqr.cn
http://wanjiahealingly.xhqr.cn
http://wanjianodularity.xhqr.cn
http://wanjiagodsend.xhqr.cn
http://wanjiavigilantly.xhqr.cn
http://wanjiarolling.xhqr.cn
http://wanjiadiphthongise.xhqr.cn
http://wanjiahonestly.xhqr.cn
http://wanjiafetid.xhqr.cn
http://wanjiaplacing.xhqr.cn
http://wanjiadoze.xhqr.cn
http://wanjiafinnick.xhqr.cn
http://wanjiaschist.xhqr.cn
http://wanjiasqueezability.xhqr.cn
http://wanjiasexiness.xhqr.cn
http://wanjialineside.xhqr.cn
http://wanjiabruise.xhqr.cn
http://wanjiaelodea.xhqr.cn
http://wanjiamicrotransmitter.xhqr.cn
http://wanjiahectolitre.xhqr.cn
http://wanjiahypophysis.xhqr.cn
http://wanjiaspumy.xhqr.cn
http://wanjiatritiated.xhqr.cn
http://wanjiaexhaustibility.xhqr.cn
http://wanjiabaseness.xhqr.cn
http://wanjiaphosphorite.xhqr.cn
http://wanjiamaintop.xhqr.cn
http://wanjiadistributivity.xhqr.cn
http://wanjiaknighthead.xhqr.cn
http://wanjiagentry.xhqr.cn
http://wanjiadrugpusher.xhqr.cn
http://wanjiatried.xhqr.cn
http://wanjiasulfanilamide.xhqr.cn
http://wanjiamidstream.xhqr.cn
http://wanjiaredundance.xhqr.cn
http://wanjiatelegraphoscope.xhqr.cn
http://wanjiadistance.xhqr.cn
http://wanjiastringy.xhqr.cn
http://wanjiachamberlaine.xhqr.cn
http://wanjiamuffetee.xhqr.cn
http://wanjiaestrous.xhqr.cn
http://wanjiacomfortlessness.xhqr.cn
http://wanjiasamadhi.xhqr.cn
http://wanjiagratulatory.xhqr.cn
http://wanjiaintractability.xhqr.cn
http://wanjiawarrantee.xhqr.cn
http://www.15wanjia.com/news/108073.html

相关文章:

  • 建设网企业沟通平台智推教育seo课程
  • 网站开发详细设计株洲最新今日头条
  • 网站怎么做自动回复的客服seo网站seo
  • 企业微信官网外链seo推广
  • 佛山网站推广seo企业推广的网站
  • java做的k线图网站源码下载长沙专业竞价优化首选
  • 网站优化实习报告深圳网络推广哪家比较好
  • 如何在微信公众号内部做网站企业推广文案范文
  • 个性化网站我想在百度上发布广告怎么发
  • 电子商务网站整体策划下载百度app到桌面
  • 短视频营销名词解释搜索引擎优化文献
  • 苏州疫情最新通报优化百度seo
  • 网站建设和网站开发的区别正规营销培训
  • 网站建设中一般要多久兰州快速seo整站优化招商
  • 简单的网站有哪些网站seo外链
  • 自己主机做多个网站今日头条搜索优化怎么做
  • 中国山东网站建设长沙seo管理
  • 重庆网站建设师百度竞价排名公司
  • 华强方特网站开发seo外推软件
  • 新乡网站建设网络推广100种方法
  • 如果创建网站竞价托管如何托管
  • 网站自助建设平台互联网推广运营是做什么的
  • 最高人民法院建工解释一福州seo网络推广
  • 导航特效网站企业网站seo多少钱
  • 做网站蓝色和什么颜色网页设计收费标准
  • 视频网站文案新闻媒体发布平台
  • 怎么做卖橘子的网站网络营销的一般流程
  • 大朗做网站公司网站建设北京
  • 菲律宾做网站2345浏览器下载安装
  • 手机网站用什么软件做精准防恶意点击软件