首页 文章 精选 留言 我的

精选列表

搜索[垃圾回收器],共10024篇文章
优秀的个人博客,低调大师

android-手机内存分配和回收机制研究

Theory: There are two kinds ofmemory allocationmechanism : (1)Somelargeapplication ,like oracle client ,world of warcraft game : ( We can think about it likeBuffet(自助餐),if you paid, you can control what you eat and do not need to pay anymore ) This kind of application will have aminimum configurationof memory ( for example ,the WOW game will have at least 1gigabyte memory) ,this minimum memory is the largest estimation of the memory that it may use,it will never ask the Operation System for extra memory when runningit .(For example ,the wow.exe only need 400m memory ,the left memory are reserved for temp files ,swap files ,object files and so on ,so even it only needs 400M,the rest 600M are unavailable for other application .) So this kind of application has only two status: (Can run / cannot run),Once it runs ,it will always run and do not need to worry about the memory . (2)Small application: Most of the normal application are acted like this way ,it applies for a small memory ,and when it runs and needs more memory ,it asked the Operation system for more memory. (we can think it as “Choose dishes from menu”(点菜),if we needs more ,we order more ,pay more) So this kind of application will have three status: (cannot run /Can run/ can run but future the memory used out) During running ,it needs more memory and applied from OS ,so maybe onetime ,the OS cannot supply enough memory, this application will shutdown. Our issue: Based on the above theory ,we can take a look at the problem ,why sometimes ,the application will shut down if we scroll the screen very frequently in search result page. Because android mobile application is usingMechanism 2 Problem:when we go to the search result page ,if we scroll down the screen very frequently ,the application thread will shut down because of the memory used out. Phenomenon: scroll down very frequently ->Dalvik VM used out exception Reason: The Heap memory can be divided into parts,one is reserved for java objects ,the other is reserved for native C objects.(They cannot mix together) If we scroll up /down the screen very frequently ,the new native objects are created andONLY the native heap memory are recycled. And the recycling speed is much slower than the allocating memory speed ,that’s why the heap memory will used out. From the log ,we can see ,that only native heap memory are recycled (GC_EXTERNAL_ALLOC stands for the native heap memory recycle) And most the memory recycled are small( less than 150KB) ,that’s because android based on “slab” mechanism to allocate memory ,and the slab has a limit size. But what the size of the native heap memory it allocated when a new native c object created? The answer is320KBin our test So,allocate more and recycle less ,at last ,the memory will used out and the application process will die. Solution; When configure the emulator ,pleaseset the RAM(SD card) to be a large number ,and restart the emulator. Go to <ANDROID_ROOT>\.android\avd\<Your avd>\config.ini ,change thesdcard.size 本文转自 charles_wang888 51CTO博客,原文链接:http://blog.51cto.com/supercharles888/835923,如需转载请自行联系原作者

优秀的个人博客,低调大师

MYSQL Rewriter plugin 我那什么拯救你,垃圾系统

从SQL 语言, DB 和 开发人员之间对SQL的撰写的目的和本质的理解就有不同,一个是要以逻辑为基础满足业务需求即可,性能方面的需求这变得不是核心人物,而DB 人员则对SQL的撰写和优化作为一个核心的目的,性能是重要的,所以矛盾就产生了. 如何解决这样的矛盾,其实日常无非几个方法 1 DB 懂得业务并且在项目之初就介入,在表设计和优化方前期就下功夫,避免开发和DB之间的矛盾,当然能做到这样的单位少之又少,原因很复杂,但大多不是技术上的问题. 2 在硬件上面做文章,软件设计的不好,硬件上给力,什么SSD ,大内存, 都给上,这样双方的矛盾也能缓解,所谓弄用钱办的事情,都不是事情,但对于项目和开发,以及DB,都不是什么好事,这些人都没有进步,这样的事情大部分发生在国企,或事业单位. 3 就是今天的要说,DB 如果管不了开发,项目,那有没有方法通过自己的手段来挽救,你所管辖的系统. 自MYSQL 8.012 可以开始进行相关的 INSERT ,UPDATE ,DELETE ,REPLACE, 提出了query rewrite plugin 组件.在此之前组件仅仅支持SELECT 语句的变更. 首先我们先确认,当前的MYSQL 是否有相关的插件和支持,这里使用的MYSQL8.019 officialcommunity 的版本,这帮 show global variables like 'lc_messages_dir'; 然后我们将组件加载到当前的MYSQL中,到响应的目录,直接执行 insert_rewriter.sql 加载到当前系统 执行后我们的MYSQL会多一个数据库,query_rewrite select plugin_name,plugin_status, plugin_version from information_schema.plugins where plugin_name='Rewriter'; 在确认以上信息后,下面就可以进行一些简单的样例 1 经常有人直接对数据库中的大表进行操作,这样的操作直接影响了系统的安全性,属于需要防范和进行取消的操作,但实际上即使有了相关的数据库审核和数据库的规范,但实际上还是不能将这一行的行为杜绝. 那下面的工作就可以帮助到你,这里我们的employees 数据库中有一个表dept_emp 表比较大3000万数据,但经常有人 select * from dept_no 这个表并且没有条件. 那我们就可以通过这个rewrite 的plug-in 将这一行的语句直接封杀. insert into queery_rewrite.rewrite_rules (id,pattern_database,pattern,replacement) values (1,'employees','select * from dept_emp','select * from dept_emp limit 1'); 我们在所在的数据库上直接执行上述语句,并且 call query_rewrite.flush_rewrite_rules(); 执行上述存储过程,让上述规则生效. 在此查询的时候,语句就不会将所有的记录抛出了,而是直接替换这个语句变成 select * fromdept_emp limit 1; 这样的形式 那如此就完事了,当然没有,如果他写成这样的形式, select * from dept_emp limit 100000;那就会显示10万条数据吗? 显然不是的我们稍加处理,让他这样的操作也不可以,当然事先要知道如此逻辑在业务中是可以通过的. insert into query_rewrite.rewrite_rules (id,pattern_database,pattern,replacement) values (2,'employees','select * from dept_emp limit ?','select * from dept_emp limit 10'); call query_rewrite.flush_rewrite_rules(); 如此执行上述语句后,他在忙活也只能显示10条数据. 这里面 ? 问好代表一个变量,也就是无论limit 后面填写什么变量,最后都是变换成 select * fromdept_emp limit 10; 那么下面我们模拟一个复杂的操作 举例我们下面的语句中我们不想让用户使用in 而是想使用 exists update employees set hire_date = '1986-08-28' where emp_no in ( select b.emp_no from (select * from employees) as b where b.hire_date > '1986-06-26'); update employees set hire_date = '1986-08-28' where exists ( select * from (select * from employees) as b where b.hire_date > '1986-06-26'); 在操作完毕后,我们直接运行 下面的语句, 或者通过explain 来看都是执行了这个 in 的语句,但我们打开general log后, 记录的执行的语句 所以通过rewrite 这个MYSQL的功能,可以将我们对程序中的一些不好的写法进行一个更改, 实际上执行的使我们替换后的语句. 当然这样的做法必须在验证这样的操作比原有操作性能更高,并且进行一段时间的验证后,才能实现. 本文分享自微信公众号 - AustinDatabases(AustinDatabases)。如有侵权,请联系 support@oschina.cn 删除。本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册