首页 文章 精选 留言 我的

精选列表

搜索[内存安全],共10000篇文章
优秀的个人博客,低调大师

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,如需转载请自行联系原作者

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

获取Android系统默认给每个app分配的内存上限

ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); int memorySize = activityManager.getMemoryClass(); 测试结果: 华为mate7:192m 小米4:128m 红米:128m 三星SM-N7508v:96m Android4.0以后,可以通过在application节点中设置属性Android:largeHeap=”true”来突破这个上限。 本文转自 一点点征服 博客园博客,原文链接:http://www.cnblogs.com/ldq2016/p/6628339.html,如需转载请自行联系原作者

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

在宿主机查看docker使用cpu、内存、网络、io情况

使用命令 docker stats [OPTIONS] [CONTAINER...] docker stats命令返回一个用于运行容器的实时数据流。要将数据限制到一个或多个特定的容器,可以指定一个由空格分隔的容器名称或ID的列表。您也可以指定一个已停止的容器,但是停止的容器不返回任何数据 显示多个容器的运行信息 docker stats dockername1 dockername2 #容器名之间用空格隔开 扩展参数 OPTIONS 默认 说明 –all, -a false 显示所有容器(默认显示刚刚运行) –format 使用Go模板打印图像 –no-stream false 禁用流统计信息,仅拉取第一个结果 查看所有容器的运行状态 docker stats -a 我的官网 我的官网http://guan2ye.com 我的CSDN地址http://blog.csdn.net/chenjianandiyi 我的简书地址http://www.jianshu.com/u/9b5d1921ce34 我的githubhttps://github.com/javanan 我的码云地址https://gitee.com/jamen/ 阿里云优惠券https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=vf2b5zld&utm_source=vf2b5zld 阿里云教程系列网站http://aliyun.guan2ye.com 我的开源项目spring boot 搭建的一个企业级快速开发脚手架

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

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

Nacos

Nacos

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

Sublime Text

Sublime Text

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

用户登录
用户注册