首页 \ 问答 \ Java中有SoftHashMap吗?(Is there a SoftHashMap in Java?)

Java中有SoftHashMap吗?(Is there a SoftHashMap in Java?)

我知道java.util中有一个WeakHashMap,但是由于它使用了WeakReferences的所有内容,这只是该Map引用的,引用的对象将在下一个GC循环中丢失。 所以如果你想缓存随机数据,这很有可能再次被请求,而不会在其余的时间被硬链接,这几乎没用。 最好的解决方案是使用SoftReferences的地图,但是我没有在Java RT Package中找到它。


I know there is a WeakHashMap in java.util, but since it uses WeakReferences for everything, which is only referenced by this Map, referenced objects will get lost on the next GC cycle. So it's nearly useless if you want to cache random data, which is very likely to be requested again without being Hard-linked the rest of the time. The best solution would be a map, which uses SoftReferences instead, but I didn't find one in the Java RT Package.


原文:https://stackoverflow.com/questions/264582
更新时间:2023-08-24 10:08

最满意答案

GDT:你没有说GDT条目的内容是什么,但是你展示的东西看起来与你链接的教程前面的部分非常相似并且如果你以相同的方式设置了条目,那么所有的都应该是好的(例如,对于CS的环0码段的平面段映射,对于其他所有的环0数据段,均具有0的基数和4GB的限制)。

IDT:如果中断被禁用并且您还没有(预计)会导致页面错误,那么可能无所谓。

页表:不正确的页表似乎是最有可能的嫌疑犯。 确保您的身份映射覆盖您正在使用的所有代码,数据和堆栈内存(至少)。

链接到http://www.jamesmolloy.co.uk/tutorial_html/6.-Paging.html底部的源代码确实可以构建出与QEMU和Bochs都可以正常工作的东西,所以希望你能比较一下你的“重新做自己正在做的事,然后弄清楚什么是错的。

QEMU总的来说很好,但我会推荐Bochs开发真正的低级别的东西 - 它包括(或可以配置为包含)一个非常方便的内部调试器 。 例如在配置文件的cpu: line上设置reset_on_triple_fault=0 ,在reset_on_triple_fault=0 switch_page_directory()代码中设置断点,运行到断点,然后单步执行指令并查看发生了什么......


GDT: you don't say what the contents of the GDT entries are, but the stuff you've shown looks fairly similar to the earlier part of the tutorial you linked to and if you've set up the entries in the same way, then all should be well (i.e. flat segment mapping with a ring 0 code segment for CS, ring 0 data segment for everything else, both with a base of 0 and a limit of 4GB).

IDT: probably doesn't matter anyway if interrupts are disabled and you're not (yet) expecting to cause page faults.

Page tables: incorrect page tables do seem like the most likely suspect. Make sure that your identity mapping covers all of the code, data and stack memory that you're using (at least).

The source code linked to at the bottom of http://www.jamesmolloy.co.uk/tutorial_html/6.-Paging.html definitely builds something that does work correctly with both QEMU and Bochs, so hopefully you can compare what you're doing with what that's doing, and work out what is wrong.

QEMU is good in general, but I would recommend Bochs for developing really low-level stuff - it includes (or can be configured to include) a very handy internal debugger. e.g. set reset_on_triple_fault=0 on the cpu: line of the config file, set a breakpoint in the switch_page_directory() code, run to the breakpoint, then single step instructions and see what happens...

相关问答

更多
  • 对,已经提示你了kernel too old。 把你的虚拟机内核升级一下吧。
  • 您将代码和数据加载到0x07E0:0x0000 。 因此,汇编器和链接器所做的所有引用都基于0x07E0:0x0000 - 例如main ,可能是0x0020或其他东西。 但是你的GDT的代码段基于0x00000000 - 所以jmp 0x8:main会将JMP为绝对地址0x00000020或其他东西 - 远不及代码位于0x00007E20或其他地方的地方。 更改GDT中段的基数,或者将代码更改为0x0000的实模式段。 You load the code and the data at 0x07E0:0x ...
  • 每当应用程序尝试访问未映射到物理地址的虚拟内存地址时,页面错误都是由CPU(更具体地说,MMU)引起的。 页面错误处理程序(在内核中)然后检查页面当前是否已交换到磁盘(交换回来)或已保留但未提交(提交),然后将控制权发送回应用程序以重试内存访问指令。 另一方面,如果应用程序没有分配该虚拟地址,则它会将segfault指令发送回内核。 因此,最准确的说硬件会触发呼叫。 The page fault is caused by the CPU (more specifically, the MMU) whenev ...
  • GDT:你没有说GDT条目的内容是什么,但是你展示的东西看起来与你链接的教程前面的部分非常相似,并且如果你以相同的方式设置了条目,那么所有的都应该是好的(例如,对于CS的环0码段的平面段映射,对于其他所有的环0数据段,均具有0的基数和4GB的限制)。 IDT:如果中断被禁用并且您还没有(预计)会导致页面错误,那么可能无所谓。 页表:不正确的页表似乎是最有可能的嫌疑犯。 确保您的身份映射覆盖您正在使用的所有代码,数据和堆栈内存(至少)。 链接到http://www.jamesmolloy.co.uk/tuto ...
  • irq0()是一个中断服务程序,以iret结束。 你无法对该例程进行C调用。 如果您确实想要触发中断,请使用int指令。 但是,您实际上并不需要手动触发定时器IRQ,一旦配置了定时器/ APIC就会触发它,并且一旦你接到中断就接收中断。 作为旁注,对于“常见的IRQ处理程序”方法而言,它被认为是不好的做法(浪费时钟周期和污染缓存),然后只做一个手动的交换机案例分支,不同的IRQ也可能需要不同的处理(例如,对于奴隶的EOI) )。 只需将处理程序直接安装到IDT中即可。 调查摘要: 经过调查后,重映射代码导致 ...
  • 鉴于提供的信息,我怀疑尚未为您的处理器启用SSE指令。 如果未启用,它们的使用将触发一个例外(我认为向量19)。 此外,如果这个向量没有正确初始化,那么我肯定会看到它导致三重错误。 有关启用处理器SSE指令的更多信息,请参阅64-ia-32架构软件开发手册第13卷第3卷。 希望这可以帮助。 Given the provided information, I suspect that the SSE instructions have not been enabled for your processor. ...
  • 我想说....大部分时间我碰到页面错误+递归内核堆栈跟踪,最有可能的堆栈溢出问题。 我从irq_exit()中发现,它试图获取curret_task_id,并且由于堆栈溢出,任务结构被破坏。 所以,转储初始崩溃转储但是backtrace()也依赖于当前的任务结构,并且不断触及page_fault或者某种无意义的回溯..... 启用动态 I would like to say.... most of time I hit page fault + recursive kernel stack trace, m ...
  • @ColinE:你在获得更多答案时遇到问题的原因是你有一些问题。 我想你至少有两个问题: 1.)“为什么要购买第三方编程组件?” (广泛而含糊的问题)和 2.)“鉴于我的具体用例,我应该购买第三方实时消息组件吗?” (具体到您的条件而不是一般知识) 不过,我会对它进行分析,试图平衡每个可能阅读此内容的人的广泛知识,然后解决您的特定用例。 我为发布Comet / Bayeux的WebSync实现的公司工作,所以我对这些东西有很多经验。 为了平等起见,我将尝试在我的术语中非常不可知,但可以假设我列出的实时消息的 ...
  • Michael Petch在评论中给出了这个问题的正确答案。 不幸的是,几个人似乎错过了这个,因为现在已经发布了三个不正确的答案,其中两个犯了同样的错误。 在这里,他的评论作为答案发布,希望它更加明显: 你确定你的GDT是正确的吗? 我认为粗略看起来很突出的是每个条目都是9字节(72位)。 GDT条目是8个字节(64位)。 似乎你的意思是db 0x0 ; Base (16-23) db 0x0 ; Base (16-23)而不是dw 0x0 ; Base (16-23) dw 0x0 ; Base (16- ...
  • 我可以想到以下几种可能性: 地址未正确对齐(movq可能需要64位对齐,这取决于您的处理器设置) 该地址无法访问,但我想你会知道数据存在(特别是因为你正在使用%rip) I can think of the following possibilities: The address is not properly aligned (movq probably requires 64 bit alignment, it depends on your processor settings) The addres ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。